subspace

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StoreKey is the string store types for the param store
	StoreKey = "params"

	// TStoreKey is the string store types for the param transient store
	TStoreKey = "transient_params"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyTable

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

KeyTable subspaces appropriate types for each parameter types

func NewKeyTable

func NewKeyTable(keytypes ...interface{}) (res KeyTable)

Constructs new table

func (KeyTable) RegisterParamSet

func (t KeyTable) RegisterParamSet(ps ParamSet) KeyTable

Register multiple pairs from ParamSet

func (KeyTable) RegisterType

func (t KeyTable) RegisterType(key []byte, ty interface{}) KeyTable

Register single types-types pair

type ParamSet

type ParamSet interface {
	ParamSetPairs() ParamSetPairs
}

type ParamSetPair

type ParamSetPair struct {
	Key         []byte
	Value       interface{}
	ValidatorFn ValueValidatorFn
}

ParamSetPair is used for associating paramsubspace key and field of param structs.

func NewParamSetPair

func NewParamSetPair(key []byte, value interface{}, vfn ValueValidatorFn) ParamSetPair

NewParamSetPair creates a new ParamSetPair instance.

type ParamSetPairs

type ParamSetPairs []ParamSetPair

type Subspace

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

Individual parameter store for each keeper Transient store persists for a block, so we use it for recording whether the parameter has been changed or not

func NewSubspace

func NewSubspace(cdc *codec.Codec, key types.StoreKey, tkey types.StoreKey, name string) (res Subspace)

NewSubspace constructs a store with namestore

func (Subspace) Get

func (s Subspace) Get(ctx types.Context, key []byte, ptr interface{})

Get parameter from store

func (Subspace) GetParamSet

func (s Subspace) GetParamSet(ctx types.Context, ps ParamSet)

Get to ParamSet

func (Subspace) HasKeyTable

func (s Subspace) HasKeyTable() bool

HasKeyTable returns if the Subspace has a KeyTable registered.

func (Subspace) Set

func (s Subspace) Set(ctx types.Context, key []byte, param interface{})

Set stores the parameter. It returns error if stored parameter has different types from input. It also set to the transient store to record change.

func (Subspace) SetParamSet

func (s Subspace) SetParamSet(ctx types.Context, ps ParamSet)

Set from ParamSet

func (Subspace) WithKeyTable

func (s Subspace) WithKeyTable(table KeyTable) Subspace

WithKeyTable initializes KeyTable and returns modified Subspace

type ValueValidatorFn

type ValueValidatorFn func(value interface{}) error
types ParamSetPair struct {
	Key		[]byte
	Value 	interface{}
}
func NewParamSetPair(key []byte, value interface{}) ParamSetPair {
	return ParamSetPair{key, value}
}

Jump to

Keyboard shortcuts

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