app

package
v0.0.0-...-b5e13e0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultKeyPass contains the default key password for genesis transactions
	DefaultKeyPass = "12345678"
)

Variables

View Source
var (
	DefaultCLIHome  = os.ExpandEnv("$HOME/.gaiacli")
	DefaultNodeHome = os.ExpandEnv("$HOME/.gaiad")
)

default home directories for expected binaries

Functions

func CollectStdTxs

func CollectStdTxs(cdc *codec.Codec, moniker string, genTxsDir string, genDoc tmtypes.GenesisDoc) (
	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 GaiaAppGenStateJSON

func GaiaAppGenStateJSON(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []json.RawMessage) (
	appState json.RawMessage, err error)

GaiaAppGenState but with JSON

func GaiaValidateGenesisState

func GaiaValidateGenesisState(genesisState GenesisState) error

GaiaValidateGenesisState ensures that the genesis state obeys the expected invariants TODO: No validators are both bonded and jailed (#2088) TODO: Error if there is a duplicate validator (#1708) TODO: Ensure all state machine parameters are in genesis (#1704)

func MakeCodec

func MakeCodec() *codec.Codec

custom tx codec 自定义tx编解码器 将相关的编码器注册到相关的各方

Types

type GaiaApp

type GaiaApp struct {
	*bam.BaseApp
	// contains filtered or unexported fields
}

Extended ABCI application

func NewGaiaApp

func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, baseAppOptions ...func(*bam.BaseApp)) *GaiaApp

################## ################## NewGaiaApp returns a reference to an initialized GaiaApp. 这个是gaia app实例 单独运行的话就是现在的 cosmos hub ################## ##################

func (*GaiaApp) BeginBlocker

func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock

application updates every end block * 每个区块执行前都会调的

与 EndBlocker 相呼应

大家写过数据库的底层操作,这个东西应该和它非常类似,不外乎是Begin准备,End结束,清扫资源

TODO 这个由 tendermint 在处理每个块之前 回调cosmos 做的 rpc 交互

func (*GaiaApp) EndBlocker

func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock

tendermint 拉取 cosmos 实时的验证人列表 TODO ################ TODO 超级重要 这个才是由 tendermint 在每个块执行结束时 回调 cosmos 的 rpc交互 application updates every end block nolint: unparam 在每个区块执行结束前 调用 DeliverTx消息处理完成所有的交易后调用,主要用来对验证人集合的结果进行维护.

func (*GaiaApp) ExportAppStateAndValidators

func (app *GaiaApp) ExportAppStateAndValidators(forZeroHeight bool, jailWhiteList []string) (
	appState json.RawMessage, validators []tmtypes.GenesisValidator, err error)

export the state of gaia for a genesis file

func (*GaiaApp) LoadHeight

func (app *GaiaApp) LoadHeight(height int64) error

load a particular height

type GenesisAccount

type GenesisAccount struct {
	Address       sdk.AccAddress `json:"address"`
	Coins         sdk.Coins      `json:"coins"`
	Sequence      uint64         `json:"sequence_number"`
	AccountNumber uint64         `json:"account_number"`

	// vesting account fields
	OriginalVesting  sdk.Coins `json:"original_vesting"`  // total vesting coins upon initialization
	DelegatedFree    sdk.Coins `json:"delegated_free"`    // delegated vested coins at time of delegation
	DelegatedVesting sdk.Coins `json:"delegated_vesting"` // delegated vesting coins at time of delegation
	StartTime        int64     `json:"start_time"`        // vesting start time (UNIX Epoch time)
	EndTime          int64     `json:"end_time"`          // vesting end time (UNIX Epoch time)
}

GenesisAccount defines an account initialized at genesis.

func NewDefaultGenesisAccount

func NewDefaultGenesisAccount(addr sdk.AccAddress) GenesisAccount

func NewGenesisAccount

func NewGenesisAccount(acc *auth.BaseAccount) GenesisAccount

func NewGenesisAccountI

func NewGenesisAccountI(acc auth.Account) GenesisAccount

func (*GenesisAccount) ToAccount

func (ga *GenesisAccount) ToAccount() auth.Account

convert GenesisAccount to auth.BaseAccount

type GenesisState

type GenesisState struct {
	Accounts     []GenesisAccount      `json:"accounts"`
	AuthData     auth.GenesisState     `json:"auth"`
	BankData     bank.GenesisState     `json:"bank"`
	StakingData  staking.GenesisState  `json:"staking"`
	MintData     mint.GenesisState     `json:"mint"`
	DistrData    distr.GenesisState    `json:"distr"`
	GovData      gov.GenesisState      `json:"gov"`
	SlashingData slashing.GenesisState `json:"slashing"`
	GenTxs       []json.RawMessage     `json:"gentxs"`
}

State to Unmarshal

func GaiaAppGenState

func GaiaAppGenState(cdc *codec.Codec, genDoc tmtypes.GenesisDoc, appGenTxs []json.RawMessage) (
	genesisState GenesisState, err error)

Create the core parameters for genesis initialization for gaia note that the pubkey input is this machines pubkey

func NewDefaultGenesisState

func NewDefaultGenesisState() GenesisState

NewDefaultGenesisState generates the default state for gaia.

func NewGenesisState

func NewGenesisState(accounts []GenesisAccount, authData auth.GenesisState,
	bankData bank.GenesisState,
	stakingData staking.GenesisState, mintData mint.GenesisState,
	distrData distr.GenesisState, govData gov.GenesisState,
	slashingData slashing.GenesisState) GenesisState

func (GenesisState) Sanitize

func (gs GenesisState) Sanitize()

Sanitize sorts accounts and coin sets.

type StakingHooks

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

StakingHooks contains combined distribution and slashing hooks needed for the staking module.

func NewStakingHooks

func NewStakingHooks(dh distr.Hooks, sh slashing.Hooks) StakingHooks

func (StakingHooks) AfterDelegationModified

func (h StakingHooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (StakingHooks) AfterValidatorBeginUnbonding

func (h StakingHooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

func (StakingHooks) AfterValidatorBonded

func (h StakingHooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

func (StakingHooks) AfterValidatorCreated

func (h StakingHooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)

nolint * 超级重要的 func 集, 都是一些AOP做法的 hook 函数

func (StakingHooks) AfterValidatorRemoved

func (h StakingHooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)

func (StakingHooks) BeforeDelegationCreated

func (h StakingHooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

创建委托之前需要做的事

func (StakingHooks) BeforeDelegationRemoved

func (h StakingHooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (StakingHooks) BeforeDelegationSharesModified

func (h StakingHooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (StakingHooks) BeforeValidatorModified

func (h StakingHooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress)

func (StakingHooks) BeforeValidatorSlashed

func (h StakingHooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec)

Directories

Path Synopsis
x
bank
Package bank contains a forked version of the bank module.
Package bank contains a forked version of the bank module.

Jump to

Keyboard shortcuts

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