storage

package
v0.0.1-rc-1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(key []byte, value []byte)

func ChangesRoot

func ChangesRoot(parent_hash int64) int64

func Clear

func Clear(key []byte)

func ClearPrefix

func ClearPrefix(key []byte, limit []byte)

func CommitTransaction

func CommitTransaction()

CommitTransaction Commit the last transaction started by `start_transaction`.

Any changes made during that transaction are committed.

Panics

Will panic if there is no open transaction.

func Exists

func Exists(key []byte) int32

func Get

func Get(key []byte) sc.Option[sc.Sequence[sc.U8]]

func GetDecode

func GetDecode[T sc.Encodable](key []byte, decodeFunc func(buffer *bytes.Buffer) T) T

GetDecode gets the storage value and returns it decoded. The result from Get is Option<sc.Sequence[sc.U8]>. If the option is empty, it returns the default value T. If the option is not empty, it decodes it using decodeFunc and returns it.

func GetDecodeOnEmpty

func GetDecodeOnEmpty[T sc.Encodable](key []byte, decodeFunc func(buffer *bytes.Buffer) T, onEmpty T) T

func NextKey

func NextKey(key int64) int64

func Read

func Read(key []byte, valueOut []byte, offset int32) sc.Option[sc.U32]

func RollbackTransaction

func RollbackTransaction()

RollbackTransaction Rollback the last transaction started by `start_transaction`.

Any changes made during that transaction are discarded.

Panics

Will panic if there is no open transaction.

func Root

func Root(version int32) []byte

func Set

func Set(key []byte, value []byte)

func StartTransaction

func StartTransaction()

StartTransaction Start a new nested transaction.

This allows to either commit or roll back all changes that are made after this call. For every transaction there must be a matching call to either `rollback_transaction` or `commit_transaction`. This is also effective for all values manipulated using the `DefaultChildStorage` API.

Warning

This is a low level API that is potentially dangerous as it can easily result in unbalanced transactions. For example, FRAME users should use high level storage abstractions.

func TakeBytes

func TakeBytes(key []byte) []byte

TakeBytes gets the storage value. The result from Get is Option<sc.Sequence[sc.U8]>. If the option is empty, it returns nil. If the option is not empty, it clears it and returns the sequence as bytes.

func TakeDecode

func TakeDecode[T sc.Encodable](key []byte, decodeFunc func(buffer *bytes.Buffer) T) T

TakeDecode gets the storage value and returns it decoded. The result from Get is Option<sc.Sequence[sc.U8]>. If the option is empty, it returns default value T. If the option is not empty, it clears it and returns decodeFunc(value).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL