cosmos-sdk: github.com/cosmos/cosmos-sdk/x/params/types Index | Files | Directories

package types

import "github.com/cosmos/cosmos-sdk/x/params/types"

To prevent namespace collision between consumer modules, we define a type Subspace. A Subspace can only be generated by the keeper, and the keeper checks the existence of the Subspace having the same name before generating the Subspace.

Consumer modules must take a Subspace (via Keeper.Subspace), not the keeper itself. This isolates each modules from the others and make them modify their respective parameters safely. Keeper can be treated as master permission for all Subspaces (via Keeper.GetSubspace), so should be passed to proper modules (ex. x/governance).

Index

Package Files

doc.go keys.go paramset.go querier.go subspace.go table.go

Constants

const (
    // ModuleName defines the module name
    ModuleName = "params"

    // QuerierRoute defines the module's query routing key
    QuerierRoute = ModuleName
)
const (
    // StoreKey is the string store key for the param store
    StoreKey = "params"

    // TStoreKey is the string store key for the param transient store
    TStoreKey = "transient_params"
)
const (
    QueryParams = "params"
)

Querier path constants

type KeyTable Uses

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

KeyTable subspaces appropriate type for each parameter key

func NewKeyTable Uses

func NewKeyTable(pairs ...ParamSetPair) KeyTable

func (KeyTable) RegisterParamSet Uses

func (t KeyTable) RegisterParamSet(ps ParamSet) KeyTable

RegisterParamSet registers multiple ParamSetPairs from a ParamSet in a KeyTable.

func (KeyTable) RegisterType Uses

func (t KeyTable) RegisterType(psp ParamSetPair) KeyTable

RegisterType registers a single ParamSetPair (key-type pair) in a KeyTable.

type ParamSet Uses

type ParamSet interface {
    ParamSetPairs() ParamSetPairs
}

ParamSet defines an interface for structs containing parameters for a module

type ParamSetPair Uses

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

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

func NewParamSetPair Uses

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

NewParamSetPair creates a new ParamSetPair instance.

type ParamSetPairs Uses

type ParamSetPairs []ParamSetPair

ParamSetPairs Slice of KeyFieldPair

type QuerySubspaceParams Uses

type QuerySubspaceParams struct {
    Subspace string
    Key      string
}

QuerySubspaceParams defines the params for querying module params by a given subspace and key.

func NewQuerySubspaceParams Uses

func NewQuerySubspaceParams(ss, key string) QuerySubspaceParams

type ReadOnlySubspace Uses

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

Wrapper of Subspace, provides immutable functions only

func (ReadOnlySubspace) Get Uses

func (ros ReadOnlySubspace) Get(ctx sdk.Context, key []byte, ptr interface{})

Get delegates a read-only Get call to the Subspace.

func (ReadOnlySubspace) GetRaw Uses

func (ros ReadOnlySubspace) GetRaw(ctx sdk.Context, key []byte) []byte

GetRaw delegates a read-only GetRaw call to the Subspace.

func (ReadOnlySubspace) Has Uses

func (ros ReadOnlySubspace) Has(ctx sdk.Context, key []byte) bool

Has delegates a read-only Has call to the Subspace.

func (ReadOnlySubspace) Modified Uses

func (ros ReadOnlySubspace) Modified(ctx sdk.Context, key []byte) bool

Modified delegates a read-only Modified call to the Subspace.

func (ReadOnlySubspace) Name Uses

func (ros ReadOnlySubspace) Name() string

Name delegates a read-only Name call to the Subspace.

type Subspace Uses

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 Uses

func NewSubspace(cdc codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key sdk.StoreKey, tkey sdk.StoreKey, name string) Subspace

NewSubspace constructs a store with namestore

func (Subspace) Get Uses

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

Get queries for a parameter by key from the Subspace's KVStore and sets the value to the provided pointer. If the value does not exist, it will panic.

func (Subspace) GetIfExists Uses

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

GetIfExists queries for a parameter by key from the Subspace's KVStore and sets the value to the provided pointer. If the value does not exist, it will perform a no-op.

func (Subspace) GetParamSet Uses

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

GetParamSet iterates through each ParamSetPair where for each pair, it will retrieve the value and set it to the corresponding value pointer provided in the ParamSetPair by calling Subspace#Get.

func (Subspace) GetRaw Uses

func (s Subspace) GetRaw(ctx sdk.Context, key []byte) []byte

GetRaw queries for the raw values bytes for a parameter by key.

func (Subspace) Has Uses

func (s Subspace) Has(ctx sdk.Context, key []byte) bool

Has returns if a parameter key exists or not in the Subspace's KVStore.

func (Subspace) HasKeyTable Uses

func (s Subspace) HasKeyTable() bool

HasKeyTable returns if the Subspace has a KeyTable registered.

func (Subspace) Modified Uses

func (s Subspace) Modified(ctx sdk.Context, key []byte) bool

Modified returns true if the parameter key is set in the Subspace's transient KVStore.

func (Subspace) Name Uses

func (s Subspace) Name() string

Name returns the name of the Subspace.

func (Subspace) Set Uses

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

Set stores a value for given a parameter key assuming the parameter type has been registered. It will panic if the parameter type has not been registered or if the value cannot be encoded. A change record is also set in the Subspace's transient KVStore to mark the parameter as modified.

func (Subspace) SetParamSet Uses

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

SetParamSet iterates through each ParamSetPair and sets the value with the corresponding parameter key in the Subspace's KVStore.

func (Subspace) Update Uses

func (s Subspace) Update(ctx sdk.Context, key, value []byte) error

Update stores an updated raw value for a given parameter key assuming the parameter type has been registered. It will panic if the parameter type has not been registered or if the value cannot be encoded. An error is returned if the raw value is not compatible with the registered type for the parameter key or if the new value is invalid as determined by the registered type's validation function.

func (Subspace) Validate Uses

func (s Subspace) Validate(ctx sdk.Context, key []byte, value interface{}) error

Validate attempts to validate a parameter value by its key. If the key is not registered or if the validation of the value fails, an error is returned.

func (Subspace) WithKeyTable Uses

func (s Subspace) WithKeyTable(table KeyTable) Subspace

WithKeyTable initializes KeyTable and returns modified Subspace

type SubspaceParamsResponse Uses

type SubspaceParamsResponse struct {
    Subspace string
    Key      string
    Value    string
}

SubspaceParamsResponse defines the response for quering parameters by subspace.

func NewSubspaceParamsResponse Uses

func NewSubspaceParamsResponse(ss, key, value string) SubspaceParamsResponse

type ValueValidatorFn Uses

type ValueValidatorFn func(value interface{}) error

Directories

PathSynopsis
proposal

Package types imports 5 packages (graph) and is imported by 21 packages. Updated 2020-08-13. Refresh now. Tools for package owners.