genutil

package
v0.2.2-0...-13ba25a Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

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

View Source
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) Name

func (AppModuleBasic) Name() string

module name

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

type MigrationCallback func(AppMap) AppMap

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

Directories

Path Synopsis
client
cli

Jump to

Keyboard shortcuts

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