keeper

package
v1.13.4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ErrFailedToParseValAddress = liberr.Error("failed to parse validator address from bech32: %s")
View Source
const (
	ErrNotFound = whoops.Errorf("item (%T) not found in store: %s")
)

Variables

This section is empty.

Functions

func EmitEvent added in v0.6.0

func EmitEvent(k HasModuleName, ctx context.Context, name string, attrs ...sdk.Attribute)

func IterAll

func IterAll[T proto.Message](store storetypes.KVStore, pu ProtoUnmarshaler) ([][]byte, []T, error)

func IterAllFnc

func IterAllFnc[T proto.Message](store storetypes.KVStore, pu ProtoUnmarshaler, fnc func([]byte, T) bool) error

func IterAllRaw added in v0.6.0

func IterAllRaw(store storetypes.KVStore, pu ProtoUnmarshaler) (keys [][]byte, values [][]byte, _err error)

func Load

func Load[T proto.Message](store storetypes.KVStore, pu ProtoUnmarshaler, key []byte) (T, error)

func Save

func Save(store storetypes.KVStore, pm ProtoMarshaler, key []byte, val proto.Message) error

func Uint64ToByte

func Uint64ToByte(n uint64) []byte

func ValAddressFromBech32 added in v1.13.0

func ValAddressFromBech32(addressCodec address.Codec, valAddr string) ([]byte, error)

Types

type Byter added in v1.10.1

type Byter interface {
	Bytes() []byte
}

type EventAttribute added in v0.6.0

type EventAttribute string

func (EventAttribute) With added in v0.6.0

func (e EventAttribute) With(value string) sdk.Attribute

type HasModuleName added in v0.6.0

type HasModuleName interface {
	ModuleName() string
}

func ModuleNameFunc added in v0.6.0

func ModuleNameFunc(moduleName string) HasModuleName

type IDGenerator

type IDGenerator struct {
	// contains filtered or unexported fields
}

func NewIDGenerator

func NewIDGenerator(sg StoreGetter, idkey []byte) IDGenerator

NewIDGenerator creates a new ID generator. IT uses idKey as a main

func (IDGenerator) GetLastID

func (i IDGenerator) GetLastID(ctx context.Context, name string) uint64

getLastID returns the last id that was inserted for the given name. If one does not exist, then it returns 0,

func (IDGenerator) IncrementNextID

func (i IDGenerator) IncrementNextID(ctx context.Context, name string) uint64

incrementNextID returns new ID which can now be used for referencing data and increments the counter internally. It returns the newly inserted ID.

func (IDGenerator) Zero

func (i IDGenerator) Zero() bool

type KVStoreWrapper added in v1.10.1

type KVStoreWrapper[T codec.ProtoMarshaler] struct {
	// contains filtered or unexported fields
}

func NewKvStoreWrapper added in v1.10.1

func NewKvStoreWrapper[T codec.ProtoMarshaler](s StoreGetterFn, ps ProtoSerializer) *KVStoreWrapper[T]

func (*KVStoreWrapper[T]) Get added in v1.10.1

func (v *KVStoreWrapper[T]) Get(ctx types.Context, key Byter) (T, error)

func (*KVStoreWrapper[T]) Iterate added in v1.12.0

func (v *KVStoreWrapper[T]) Iterate(ctx types.Context, fn func([]byte, T) bool) error

func (*KVStoreWrapper[T]) Set added in v1.10.1

func (v *KVStoreWrapper[T]) Set(ctx types.Context, key Byter, value T) error

type KeeperUtil added in v1.4.0

type KeeperUtil[T codec.ProtoMarshaler] struct {
	Val T
}

func (KeeperUtil[T]) Load added in v1.4.0

func (ku KeeperUtil[T]) Load(store storetypes.KVStore, pu ProtoUnmarshaler, key []byte) (T, error)

func (KeeperUtil[T]) Save added in v1.4.0

func (ku KeeperUtil[T]) Save(store storetypes.KVStore, pm ProtoMarshaler, key []byte, val codec.ProtoMarshaler) error

type KeeperUtilI added in v1.4.0

type KeeperUtilI[T codec.ProtoMarshaler] interface {
	Save(store storetypes.KVStore, pm ProtoMarshaler, key []byte, val codec.ProtoMarshaler) error
	Load(store storetypes.KVStore, pu ProtoUnmarshaler, key []byte) (T, error)
}

type ProtoMarshaler added in v1.4.0

type ProtoMarshaler interface {
	Marshal(ptr proto.Message) ([]byte, error)
}

type ProtoSerializer added in v1.10.1

type ProtoSerializer interface {
	ProtoMarshaler
	ProtoUnmarshaler
}

type ProtoUnmarshaler added in v1.4.0

type ProtoUnmarshaler interface {
	Unmarshal(bz []byte, ptr proto.Message) error
}

type StoreGetter

type StoreGetter interface {
	Store(ctx context.Context) storetypes.KVStore
}

func SimpleStoreGetter

func SimpleStoreGetter(s storetypes.KVStore) StoreGetter

type StoreGetterFn

type StoreGetterFn func(ctx context.Context) storetypes.KVStore

func (StoreGetterFn) Store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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