2019-12-17 03:44:44 -08:00
|
|
|
<!--
|
2019-12-11 09:35:27 -08:00
|
|
|
order: 2
|
2019-12-17 03:44:44 -08:00
|
|
|
-->
|
2019-12-11 09:35:27 -08:00
|
|
|
|
2018-10-13 10:29:59 -07:00
|
|
|
# Subspace
|
|
|
|
|
2021-05-27 08:31:04 -07:00
|
|
|
`Subspace` is a prefixed subspace of the parameter store. Each module which uses the
|
2021-01-15 05:30:17 -08:00
|
|
|
parameter store will take a `Subspace` to isolate permission to access.
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2019-02-04 18:13:04 -08:00
|
|
|
## Key
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2021-05-27 08:31:04 -07:00
|
|
|
Parameter keys are human readable alphanumeric strings. A parameter for the key
|
|
|
|
`"ExampleParameter"` is stored under `[]byte("SubspaceName" + "/" + "ExampleParameter")`,
|
2020-07-01 06:27:13 -07:00
|
|
|
where `"SubspaceName"` is the name of the subspace.
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2020-07-01 06:27:13 -07:00
|
|
|
Subkeys are secondary parameter keys those are used along with a primary parameter key.
|
|
|
|
Subkeys can be used for grouping or dynamic parameter key generation during runtime.
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2019-02-04 18:13:04 -08:00
|
|
|
## KeyTable
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2021-05-27 08:31:04 -07:00
|
|
|
All of the parameter keys that will be used should be registered at the compile
|
2020-07-01 06:27:13 -07:00
|
|
|
time. `KeyTable` is essentially a `map[string]attribute`, where the `string` is a parameter key.
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2021-05-27 08:31:04 -07:00
|
|
|
Currently, `attribute` consists of a `reflect.Type`, which indicates the parameter
|
2021-01-15 05:30:17 -08:00
|
|
|
type to check that provided key and value are compatible and registered, as well as a function `ValueValidatorFn` to validate values.
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2021-05-27 08:31:04 -07:00
|
|
|
Only primary keys have to be registered on the `KeyTable`. Subkeys inherit the
|
2020-07-01 06:27:13 -07:00
|
|
|
attribute of the primary key.
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2019-02-04 18:13:04 -08:00
|
|
|
## ParamSet
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2021-01-15 05:30:17 -08:00
|
|
|
Modules often define parameters as a proto message. The generated struct can implement
|
|
|
|
`ParamSet` interface to be used with the following methods:
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2019-02-04 18:13:04 -08:00
|
|
|
* `KeyTable.RegisterParamSet()`: registers all parameters in the struct
|
|
|
|
* `Subspace.{Get, Set}ParamSet()`: Get to & Set from the struct
|
2018-10-13 10:29:59 -07:00
|
|
|
|
2021-01-15 05:30:17 -08:00
|
|
|
The implementor should be a pointer in order to use `GetParamSet()`.
|