support

package
v0.0.2-rc-2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashStorageMap

type HashStorageMap[K, V sc.Encodable] struct {
	// contains filtered or unexported fields
}

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]) Mutate

func (hsm HashStorageMap[K, V]) Mutate(k K, f func(*V) (sc.Encodable, error)) (sc.Encodable, 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)

func (HashStorageMap[K, V]) TryMutateExists

func (hsm HashStorageMap[K, V]) TryMutateExists(k K, f func(option *sc.Option[V]) (sc.Encodable, error)) (sc.Encodable, error)

type HashStorageValue

type HashStorageValue[T sc.Encodable] struct {
	// contains filtered or unexported fields
}

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]) DecodeLen

func (hsv HashStorageValue[T]) DecodeLen() (sc.Option[sc.U64], error)

func (HashStorageValue[T]) Exists

func (hsv HashStorageValue[T]) Exists() bool

func (HashStorageValue[T]) Get

func (hsv HashStorageValue[T]) Get() (T, error)

func (HashStorageValue[T]) GetBytes

func (hsv HashStorageValue[T]) GetBytes() (sc.Option[sc.Sequence[sc.U8]], 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

type Layer = sc.U32

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)

func (RawStorageValue) Get

func (rsv RawStorageValue) Get() (sc.Sequence[sc.U8], error)

Get a sequence of bytes from storage.

func (RawStorageValue) Put

func (rsv RawStorageValue) Put(value sc.Sequence[sc.U8])

Put a raw byte slice into storage.

type SimpleStorageValue

type SimpleStorageValue[T sc.Encodable] struct {
	// contains filtered or unexported fields
}

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]) DecodeLen

func (ssv SimpleStorageValue[T]) DecodeLen() (sc.Option[sc.U64], error)

func (SimpleStorageValue[T]) Exists

func (ssv SimpleStorageValue[T]) Exists() bool

func (SimpleStorageValue[T]) Get

func (ssv SimpleStorageValue[T]) Get() (T, error)

func (SimpleStorageValue[T]) GetBytes

func (ssv SimpleStorageValue[T]) GetBytes() (sc.Option[sc.Sequence[sc.U8]], 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)
}

func NewHashStorageMap

func NewHashStorageMap[K, V sc.Encodable](prefix []byte, name []byte, keyHashFunc func([]byte) []byte, decodeFunc func(buffer *bytes.Buffer) (V, error)) StorageMap[K, V]

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 NewHashStorageValue[T sc.Encodable](prefix []byte, name []byte, decodeFunc func(buffer *bytes.Buffer) (T, error)) StorageValue[T]

func NewHashStorageValueWithDefault

func NewHashStorageValueWithDefault[T sc.Encodable](prefix []byte, name []byte, decodeFunc func(buffer *bytes.Buffer) (T, error), defaultValue *T) StorageValue[T]

func NewSimpleStorageValue

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

type Transactional

type Transactional[T sc.Encodable] interface {
	WithStorageLayer(fn func() (T, error)) (T, error)
}

func NewTransactional

func NewTransactional[T sc.Encodable](logger log.WarnLogger) Transactional[T]

Jump to

Keyboard shortcuts

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