Documentation ¶
Index ¶
- type HashStorageMap
- func (hsm HashStorageMap[K, V]) Append(k K, value V)
- func (hsm HashStorageMap[K, V]) Clear(limit sc.U32)
- func (hsm HashStorageMap[K, V]) Exists(k K) bool
- func (hsm HashStorageMap[K, V]) Get(k K) (V, error)
- func (hsm HashStorageMap[K, V]) Mutate(k K, f func(*V) (sc.Encodable, error)) (sc.Encodable, error)
- func (hsm HashStorageMap[K, V]) Put(k K, value V)
- func (hsm HashStorageMap[K, V]) Remove(k K)
- func (hsm HashStorageMap[K, V]) TakeBytes(k K) ([]byte, error)
- func (hsm HashStorageMap[K, V]) TryMutateExists(k K, f func(option *sc.Option[V]) (sc.Encodable, error)) (sc.Encodable, error)
- type HashStorageValue
- func (hsv HashStorageValue[T]) Append(value T)
- func (hsv HashStorageValue[T]) AppendItem(value sc.Encodable)
- func (hsv HashStorageValue[T]) Clear()
- func (hsv HashStorageValue[T]) DecodeLen() (sc.Option[sc.U64], error)
- func (hsv HashStorageValue[T]) Exists() bool
- func (hsv HashStorageValue[T]) Get() (T, error)
- func (hsv HashStorageValue[T]) GetBytes() (sc.Option[sc.Sequence[sc.U8]], error)
- func (hsv HashStorageValue[T]) Mutate(f func(*T) (T, error)) (T, error)
- func (hsv HashStorageValue[T]) Put(value T)
- func (hsv HashStorageValue[T]) Take() (T, error)
- func (hsv HashStorageValue[T]) TakeBytes() ([]byte, error)
- type Layer
- type RawStorageValue
- type SimpleStorageValue
- func (ssv SimpleStorageValue[T]) Append(value T)
- func (ssv SimpleStorageValue[T]) AppendItem(value sc.Encodable)
- func (ssv SimpleStorageValue[T]) Clear()
- func (ssv SimpleStorageValue[T]) DecodeLen() (sc.Option[sc.U64], error)
- func (ssv SimpleStorageValue[T]) Exists() bool
- func (ssv SimpleStorageValue[T]) Get() (T, error)
- func (ssv SimpleStorageValue[T]) GetBytes() (sc.Option[sc.Sequence[sc.U8]], error)
- func (ssv SimpleStorageValue[T]) Mutate(f func(*T) (T, error)) (T, error)
- func (ssv SimpleStorageValue[T]) Put(value T)
- func (ssv SimpleStorageValue[T]) Take() (T, error)
- func (ssv SimpleStorageValue[T]) TakeBytes() ([]byte, error)
- type StorageMap
- type StorageRawValue
- type StorageValue
- func NewHashStorageValue[T sc.Encodable](prefix []byte, name []byte, decodeFunc func(buffer *bytes.Buffer) (T, error)) StorageValue[T]
- func NewHashStorageValueWithDefault[T sc.Encodable](prefix []byte, name []byte, decodeFunc func(buffer *bytes.Buffer) (T, error), ...) StorageValue[T]
- func NewSimpleStorageValue[T sc.Encodable](key []byte, decodeFunc func(buffer *bytes.Buffer) (T, error)) StorageValue[T]
- type Transactional
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashStorageMap ¶
HashStorageMap is a key-value storage map, which takes `prefix` and `name` that are hashed using hashing.Twox128 and appended before each key value.
func (HashStorageMap[K, V]) Append ¶
func (hsm HashStorageMap[K, V]) Append(k K, value V)
func (HashStorageMap[K, V]) Clear ¶
func (hsm HashStorageMap[K, V]) Clear(limit sc.U32)
func (HashStorageMap[K, V]) Exists ¶
func (hsm HashStorageMap[K, V]) Exists(k K) bool
func (HashStorageMap[K, V]) Get ¶
func (hsm HashStorageMap[K, V]) Get(k K) (V, error)
func (HashStorageMap[K, V]) Put ¶
func (hsm HashStorageMap[K, V]) Put(k K, value V)
func (HashStorageMap[K, V]) Remove ¶
func (hsm HashStorageMap[K, V]) Remove(k K)
func (HashStorageMap[K, V]) TakeBytes ¶
func (hsm HashStorageMap[K, V]) TakeBytes(k K) ([]byte, error)
type HashStorageValue ¶
HashStorageValue is a storage value, which takes `prefix` and `name` that are hashed using hashing.Twox128 and appended before each key value.
func (HashStorageValue[T]) Append ¶
func (hsv HashStorageValue[T]) Append(value T)
func (HashStorageValue[T]) AppendItem ¶
func (hsv HashStorageValue[T]) AppendItem(value sc.Encodable)
TODO: support appending values with type different from T
func (HashStorageValue[T]) Clear ¶
func (hsv HashStorageValue[T]) Clear()
func (HashStorageValue[T]) Exists ¶
func (hsv HashStorageValue[T]) Exists() bool
func (HashStorageValue[T]) Get ¶
func (hsv HashStorageValue[T]) Get() (T, error)
func (HashStorageValue[T]) Mutate ¶
func (hsv HashStorageValue[T]) Mutate(f func(*T) (T, error)) (T, error)
func (HashStorageValue[T]) Put ¶
func (hsv HashStorageValue[T]) Put(value T)
func (HashStorageValue[T]) Take ¶
func (hsv HashStorageValue[T]) Take() (T, error)
func (HashStorageValue[T]) TakeBytes ¶
func (hsv HashStorageValue[T]) TakeBytes() ([]byte, error)
type Layer ¶
Layer is the type that is being used to store the current number of active layers.
const TransactionalLimit Layer = 255
TransactionalLimit returns the maximum number of nested layers.
type RawStorageValue ¶
type RawStorageValue struct {
// contains filtered or unexported fields
}
The value is stored as raw bytes, without encoding, thus, it is always a sequence of bytes.
func (RawStorageValue) Clear ¶
func (rsv RawStorageValue) Clear()
func (RawStorageValue) ClearPrefix ¶
func (rsv RawStorageValue) ClearPrefix(limit sc.U32)
type SimpleStorageValue ¶
SimpleStorageValue takes a key upon initialisation and uses it in raw format to get storage values.
func (SimpleStorageValue[T]) Append ¶
func (ssv SimpleStorageValue[T]) Append(value T)
func (SimpleStorageValue[T]) AppendItem ¶
func (ssv SimpleStorageValue[T]) AppendItem(value sc.Encodable)
TODO: support appending values with type different from T
func (SimpleStorageValue[T]) Clear ¶
func (ssv SimpleStorageValue[T]) Clear()
func (SimpleStorageValue[T]) Exists ¶
func (ssv SimpleStorageValue[T]) Exists() bool
func (SimpleStorageValue[T]) Get ¶
func (ssv SimpleStorageValue[T]) Get() (T, error)
func (SimpleStorageValue[T]) Mutate ¶
func (ssv SimpleStorageValue[T]) Mutate(f func(*T) (T, error)) (T, error)
func (SimpleStorageValue[T]) Put ¶
func (ssv SimpleStorageValue[T]) Put(value T)
func (SimpleStorageValue[T]) Take ¶
func (ssv SimpleStorageValue[T]) Take() (T, error)
func (SimpleStorageValue[T]) TakeBytes ¶
func (ssv SimpleStorageValue[T]) TakeBytes() ([]byte, error)
type StorageMap ¶
type StorageMap[K, V sc.Encodable] interface { Get(k K) (V, error) Exists(k K) bool Put(k K, value V) Append(k K, value V) TakeBytes(k K) ([]byte, error) Remove(k K) Clear(limit sc.U32) Mutate(k K, f func(v *V) (sc.Encodable, error)) (sc.Encodable, error) TryMutateExists(k K, f func(option *sc.Option[V]) (sc.Encodable, error)) (sc.Encodable, error) }
type StorageRawValue ¶
type StorageRawValue interface { Get() (sc.Sequence[sc.U8], error) Put(value sc.Sequence[sc.U8]) Clear() ClearPrefix(limit sc.U32) }
func NewRawStorageValue ¶
func NewRawStorageValue(key []byte) StorageRawValue
func NewRawStorageValueFrom ¶
func NewRawStorageValueFrom(storage io.Storage, key []byte) StorageRawValue
type StorageValue ¶
type StorageValue[T sc.Encodable] interface { Get() (T, error) GetBytes() (sc.Option[sc.Sequence[sc.U8]], error) Exists() bool Put(value T) Clear() Append(value T) // TODO: // support appending values with type different from T AppendItem(value sc.Encodable) TakeBytes() ([]byte, error) Take() (T, error) DecodeLen() (sc.Option[sc.U64], error) Mutate(f func(*T) (T, error)) (T, error) }
func NewHashStorageValue ¶
func NewSimpleStorageValue ¶
type Transactional ¶
func NewTransactional ¶
func NewTransactional[T sc.Encodable](logger log.WarnLogger) Transactional[T]