github.com/cosmos/cosmos-sdk@v0.50.10/x/params/README.md (about)

     1  ---
     2  sidebar_position: 1
     3  ---
     4  
     5  # `x/params`
     6  
     7  > Note: The Params module has been depreacted in favour of each module housing its own parameters. 
     8  
     9  ## Abstract
    10  
    11  Package params provides a globally available parameter store.
    12  
    13  There are two main types, Keeper and Subspace. Subspace is an isolated namespace for a
    14  paramstore, where keys are prefixed by preconfigured spacename. Keeper has a
    15  permission to access all existing spaces.
    16  
    17  Subspace can be used by the individual keepers, which need a private parameter store
    18  that the other keepers cannot modify. The params Keeper can be used to add a route to `x/gov` router in order to modify any parameter in case a proposal passes.
    19  
    20  The following contents explains how to use params module for master and user modules.
    21  
    22  ## Contents
    23  
    24  * [Keeper](#keeper)
    25  * [Subspace](#subspace)
    26      * [Key](#key)
    27      * [KeyTable](#keytable)
    28      * [ParamSet](#paramset)
    29  
    30  ## Keeper
    31  
    32  In the app initialization stage, [subspaces](#subspace) can be allocated for other modules' keeper using `Keeper.Subspace` and are stored in `Keeper.spaces`. Then, those modules can have a reference to their specific parameter store through `Keeper.GetSubspace`.
    33  
    34  Example:
    35  
    36  ```go
    37  type ExampleKeeper struct {
    38  	paramSpace paramtypes.Subspace
    39  }
    40  
    41  func (k ExampleKeeper) SetParams(ctx sdk.Context, params types.Params) {
    42  	k.paramSpace.SetParamSet(ctx, &params)
    43  }
    44  ```
    45  
    46  ## Subspace
    47  
    48  `Subspace` is a prefixed subspace of the parameter store. Each module which uses the
    49  parameter store will take a `Subspace` to isolate permission to access.
    50  
    51  ### Key
    52  
    53  Parameter keys are human readable alphanumeric strings. A parameter for the key
    54  `"ExampleParameter"` is stored under `[]byte("SubspaceName" + "/" + "ExampleParameter")`,
    55  	where `"SubspaceName"` is the name of the subspace.
    56  
    57  Subkeys are secondary parameter keys those are used along with a primary parameter key.
    58  Subkeys can be used for grouping or dynamic parameter key generation during runtime.
    59  
    60  ### KeyTable
    61  
    62  All of the parameter keys that will be used should be registered at the compile
    63  time. `KeyTable` is essentially a `map[string]attribute`, where the `string` is a parameter key.
    64  
    65  Currently, `attribute` consists of a `reflect.Type`, which indicates the parameter
    66  type to check that provided key and value are compatible and registered, as well as a function `ValueValidatorFn` to validate values.
    67  
    68  Only primary keys have to be registered on the `KeyTable`. Subkeys inherit the
    69  attribute of the primary key.
    70  
    71  ### ParamSet
    72  
    73  Modules often define parameters as a proto message. The generated struct can implement
    74  `ParamSet` interface to be used with the following methods:
    75  
    76  * `KeyTable.RegisterParamSet()`: registers all parameters in the struct
    77  * `Subspace.{Get, Set}ParamSet()`: Get to & Set from the struct
    78  
    79  The implementor should be a pointer in order to use `GetParamSet()`.