Documentation ¶
Overview ¶
Package genutil contains a variety of genesis utility functionality for usage within a blockchain application. Namely:
- Genesis transactions related (gentx)
- commands for collection and creation of gentxs
- initchain processing of gentxs
- Genesis file validation
- Tendermint related initialization
Index ¶
- Constants
- func CollectStdTxs(cdc *codec.Codec, moniker, genTxsDir string, genDoc tmtypes.GenesisDoc, ...) (appGenTxs []auth.StdTx, persistentPeers string, err error)
- func DeliverGenTxs(ctx sdk.Context, cdc *codec.Codec, genTxs []json.RawMessage, ...) []abci.ValidatorUpdate
- func ExportGenesisFile(genDoc *tmtypes.GenesisDoc, genFile string) error
- func ExportGenesisFileWithTime(genFile, chainID string, validators []tmtypes.GenesisValidator, ...) error
- func GenAppStateFromConfig(cdc *codec.Codec, config *cfg.Config, initCfg InitConfig, ...) (appState json.RawMessage, err error)
- func GenesisStateFromGenDoc(cdc *codec.Codec, genDoc tmtypes.GenesisDoc) (genesisState map[string]json.RawMessage, err error)
- func GenesisStateFromGenFile(cdc *codec.Codec, genFile string) (genesisState map[string]json.RawMessage, genDoc *tmtypes.GenesisDoc, err error)
- func InitGenesis(ctx sdk.Context, cdc *codec.Codec, stakingKeeper StakingKeeper, ...) []abci.ValidatorUpdate
- func InitializeNodeValidatorFiles(config *cfg.Config) (nodeID string, valPubKey crypto.PubKey, err error)
- func NewAppModule(accountKeeper AccountKeeper, stakingKeeper StakingKeeper, ...) module.AppModule
- func SetGenTxsInAppGenesisState(cdc *codec.Codec, appGenesisState map[string]json.RawMessage, ...) (map[string]json.RawMessage, error)
- func SetGenesisStateInAppState(cdc *codec.Codec, appState map[string]json.RawMessage, ...) map[string]json.RawMessage
- func ValidateAccountInGenesis(appGenesisState map[string]json.RawMessage, ...) error
- func ValidateGenesis(genesisState GenesisState) error
- type AccountKeeper
- type AppMap
- type AppModule
- type AppModuleBasic
- func (AppModuleBasic) DefaultGenesis() json.RawMessage
- func (AppModuleBasic) GetQueryCmd(_ *codec.Codec) *cobra.Command
- func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command
- func (AppModuleBasic) Name() string
- func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
- func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router, kafkaBool bool, ...)
- func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
- type GenesisAccountsIterator
- type GenesisState
- type InitConfig
- type MigrationCallback
- type MigrationMap
- type StakingKeeper
Constants ¶
const ModuleName = "genutil"
module name
Variables ¶
This section is empty.
Functions ¶
func CollectStdTxs ¶
func CollectStdTxs(cdc *codec.Codec, moniker, genTxsDir string, genDoc tmtypes.GenesisDoc, genAccIterator GenesisAccountsIterator, ) (appGenTxs []auth.StdTx, persistentPeers string, err error)
CollectStdTxs processes and validates application's genesis StdTxs and returns the list of appGenTxs, and persistent peers required to generate genesis.json.
func DeliverGenTxs ¶
func DeliverGenTxs(ctx sdk.Context, cdc *codec.Codec, genTxs []json.RawMessage, stakingKeeper StakingKeeper, deliverTx deliverTxfn) []abci.ValidatorUpdate
deliver a genesis transaction
func ExportGenesisFile ¶
func ExportGenesisFile(genDoc *tmtypes.GenesisDoc, genFile string) error
ExportGenesisFile creates and writes the genesis configuration to disk. An error is returned if building or writing the configuration to file fails.
func ExportGenesisFileWithTime ¶
func ExportGenesisFileWithTime( genFile, chainID string, validators []tmtypes.GenesisValidator, appState json.RawMessage, genTime time.Time, ) error
ExportGenesisFileWithTime creates and writes the genesis configuration to disk. An error is returned if building or writing the configuration to file fails.
func GenAppStateFromConfig ¶
func GenAppStateFromConfig(cdc *codec.Codec, config *cfg.Config, initCfg InitConfig, genDoc tmtypes.GenesisDoc, genAccIterator GenesisAccountsIterator, ) (appState json.RawMessage, err error)
get the genesis app state from the config
func GenesisStateFromGenDoc ¶
func GenesisStateFromGenDoc(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, ) (genesisState map[string]json.RawMessage, err error)
Create the core parameters for genesis initialization for the application.
NOTE: The pubkey input is this machines pubkey.
func GenesisStateFromGenFile ¶
func GenesisStateFromGenFile(cdc *codec.Codec, genFile string, ) (genesisState map[string]json.RawMessage, genDoc *tmtypes.GenesisDoc, err error)
Create the core parameters for genesis initialization for the application.
NOTE: The pubkey input is this machines pubkey.
func InitGenesis ¶
func InitGenesis(ctx sdk.Context, cdc *codec.Codec, stakingKeeper StakingKeeper, deliverTx deliverTxfn, genesisState GenesisState) []abci.ValidatorUpdate
initialize accounts and deliver genesis transactions
func InitializeNodeValidatorFiles ¶
func InitializeNodeValidatorFiles(config *cfg.Config, ) (nodeID string, valPubKey crypto.PubKey, err error)
InitializeNodeValidatorFiles creates private validator and p2p configuration files.
func NewAppModule ¶
func NewAppModule(accountKeeper AccountKeeper, stakingKeeper StakingKeeper, deliverTx deliverTxfn) module.AppModule
NewAppModule creates a new AppModule object
func SetGenTxsInAppGenesisState ¶
func SetGenTxsInAppGenesisState(cdc *codec.Codec, appGenesisState map[string]json.RawMessage, genTxs []auth.StdTx) (map[string]json.RawMessage, error)
Set the genesis transactions int the app genesis state
func SetGenesisStateInAppState ¶
func SetGenesisStateInAppState(cdc *codec.Codec, appState map[string]json.RawMessage, genesisState GenesisState) map[string]json.RawMessage
set the genutil genesis state within the expected app state
func ValidateAccountInGenesis ¶
func ValidateAccountInGenesis(appGenesisState map[string]json.RawMessage, genAccIterator GenesisAccountsIterator, key sdk.AccAddress, coins sdk.Coins, cdc *codec.Codec) error
ValidateAccountInGenesis checks that the provided key has sufficient coins in the genesis accounts
func ValidateGenesis ¶
func ValidateGenesis(genesisState GenesisState) error
validate GenTx transactions
Types ¶
type AccountKeeper ¶
type AccountKeeper interface { NewAccount(sdk.Context, auth.Account) auth.Account SetAccount(sdk.Context, auth.Account) IterateAccounts(ctx sdk.Context, process func(auth.Account) (stop bool)) }
expected account keeper
type AppMap ¶
type AppMap map[string]json.RawMessage
AppMap map modules names with their json raw representation
type AppModule ¶
type AppModule struct { AppModuleBasic // contains filtered or unexported fields }
___________________________ app module
func (AppModule) ExportGenesis ¶
func (am AppModule) ExportGenesis(ctx sdk.Context) json.RawMessage
module export genesis
func (AppModule) InitGenesis ¶
func (am AppModule) InitGenesis(ctx sdk.Context, data json.RawMessage) []abci.ValidatorUpdate
module init-genesis
type AppModuleBasic ¶
type AppModuleBasic struct{}
app module basics object
func (AppModuleBasic) DefaultGenesis ¶
func (AppModuleBasic) DefaultGenesis() json.RawMessage
default genesis state
func (AppModuleBasic) GetQueryCmd ¶
func (AppModuleBasic) GetQueryCmd(_ *codec.Codec) *cobra.Command
get the root query command of this module
func (AppModuleBasic) GetTxCmd ¶
func (AppModuleBasic) GetTxCmd(_ *codec.Codec) *cobra.Command
get the root tx command of this module
func (AppModuleBasic) RegisterCodec ¶
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec)
register module codec
func (AppModuleBasic) RegisterRESTRoutes ¶
func (AppModuleBasic) RegisterRESTRoutes(ctx context.CLIContext, rtr *mux.Router, kafkaBool bool, kafkaState kafka.KafkaState)
register rest routes
func (AppModuleBasic) ValidateGenesis ¶
func (AppModuleBasic) ValidateGenesis(bz json.RawMessage) error
module validate genesis
type GenesisAccountsIterator ¶
type GenesisAccountsIterator interface { IterateGenesisAccounts( cdc *codec.Codec, appGenesis map[string]json.RawMessage, iterateFn func(auth.Account) (stop bool), ) }
The expected interface for iterating genesis accounts object
type GenesisState ¶
type GenesisState struct {
GenTxs []json.RawMessage `json:"gentxs" yaml:"gentxs"`
}
State to Unmarshal
func GetGenesisStateFromAppState ¶
func GetGenesisStateFromAppState(cdc *codec.Codec, appState map[string]json.RawMessage) GenesisState
get the genutil genesis state from the expected app state
func NewGenesisState ¶
func NewGenesisState(genTxs []json.RawMessage) GenesisState
NewGenesisState creates a new GenesisState object
func NewGenesisStateFromStdTx ¶
func NewGenesisStateFromStdTx(genTxs []auth.StdTx) GenesisState
NewGenesisStateFromStdTx creates a new GenesisState object from auth transactions
type InitConfig ¶
type InitConfig struct { ChainID string GenTxsDir string Name string NodeID string ValPubKey crypto.PubKey }
common config options for init
func NewInitConfig ¶
func NewInitConfig(chainID, genTxsDir, name, nodeID string, valPubKey crypto.PubKey) InitConfig
NewInitConfig creates a new InitConfig object
type MigrationCallback ¶
MigrationCallback converts a genesis map from the previous version to the targeted one
type MigrationMap ¶
type MigrationMap map[string]MigrationCallback
MigrationMap defines a mapping from a version to a MigrationCallback
type StakingKeeper ¶
type StakingKeeper interface {
ApplyAndReturnValidatorSetUpdates(sdk.Context) (updates []abci.ValidatorUpdate)
}
expected staking keeper