Documentation ¶
Index ¶
- Variables
- func ExecCommitBlock(appConnConsensus proxy.AppConnConsensus, block *types.Block, logger log.Logger) (*abci.ResponseCommit, error)
- func LoadABCITxResponses(db dbm.DB, tx cmn.HexBytes) (abci.ResponseDeliverTx, error)
- func LoadConsensusParams(db dbm.DB, height int64) (types.ConsensusParams, error)
- func LoadValidators(db dbm.DB, height int64) (*types.ValidatorSet, error)
- func MakeGenesisDocFromFile(config *cfg.Config) (*types.GenesisDoc, error)
- func SaveLastState(db dbm.DB, lastState State)
- func SaveState(db dbm.DB, s State)
- func VerifyEvidence(stateDB dbm.DB, s State, evidence types.Evidence) error
- type ABCIResponses
- type BlockExecutor
- func (blockExec *BlockExecutor) ApplyBlock(s State, blockID types.BlockID, block *types.Block) (State, error)
- func (blockExec *BlockExecutor) Commit(block *types.Block) (*abci.ResponseCommit, error)
- func (blockExec *BlockExecutor) SetEventBus(eventBus types.BlockEventPublisher)
- func (blockExec *BlockExecutor) ValidateBlock(s State, block *types.Block) error
- type BlockStoreStateJSON
- type ConsensusParamsInfo
- type ErrAppBlockHeightTooHigh
- type ErrBlockHashMismatch
- type ErrInvalidBlock
- type ErrLastStateMismatch
- type ErrNoABCIResponsesForHeight
- type ErrNoABCITxResponseForTxHash
- type ErrNoConsensusParamsForHeight
- type ErrNoLastQueueHashForQueueID
- type ErrNoLastQueueHeightForQueueID
- type ErrNoValSetForHeight
- type ErrProxyAppConn
- type ErrStateMismatch
- type ErrUnknownBlock
- type SetTdmConfig
- type State
- func LoadLastState(db dbm.DB) State
- func LoadState(db dbm.DB) State
- func LoadStateFromDBOrGenesisDoc(stateDBx dbm.DB, stateDB dbm.DB, genesisDoc *types.GenesisDoc) (State, error)
- func LoadStateFromDBOrGenesisFile(stateDBx dbm.DB, config *cfg.Config) (State, error)
- func MakeGenesisState(genDoc *types.GenesisDoc) (State, error)
- func MakeGenesisStateFromFile(config *cfg.Config) (State, error)
- func (s State) Bytes() []byte
- func (s State) Copy() State
- func (s State) Equals(s2 State) bool
- func (s State) GetValidators() (last *types.ValidatorSet, current *types.ValidatorSet)
- func (s State) IsEmpty() bool
- func (s State) MakeBlock(height int64, txs []types.Tx, commit *types.Commit, proposer crypto.Address, ...) (*types.Block, *types.PartSet)
- type ValidatorsInfo
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ExecCommitBlock ¶
func ExecCommitBlock(appConnConsensus proxy.AppConnConsensus, block *types.Block, logger log.Logger) (*abci.ResponseCommit, error)
ExecCommitBlock executes and commits a block on the proxyApp without validating or mutating the state. It returns the application root hash (result of abci.Commit).
func LoadABCITxResponses ¶
func LoadConsensusParams ¶
LoadConsensusParams loads the ConsensusParams for a given height.
func LoadValidators ¶
LoadValidators loads the ValidatorSet for a given height. Returns ErrNoValSetForHeight if the validator set can't be found for this height.
func MakeGenesisDocFromFile ¶
func MakeGenesisDocFromFile(config *cfg.Config) (*types.GenesisDoc, error)
MakeGenesisDocFromFile reads and unmarshals genesis doc from the given file.
func SaveLastState ¶
Types ¶
type ABCIResponses ¶
type ABCIResponses struct { DeliverTx []*abci.ResponseDeliverTx EndBlock *abci.ResponseEndBlock }
ABCIResponses retains the responses of the various ABCI calls during block processing. It is persisted to disk for each height before calling Commit.
func LoadABCIResponses ¶
func LoadABCIResponses(db dbm.DB, height int64) (*ABCIResponses, error)
LoadABCIResponses loads the ABCIResponses for the given height from the database. This is useful for recovering from crashes where we called app.Commit and before we called s.Save(). It can also be used to produce Merkle proofs of the result of txs.
func NewABCIResponses ¶
func NewABCIResponses(block *types.Block) *ABCIResponses
NewABCIResponses returns a new ABCIResponses
func (*ABCIResponses) Bytes ¶
func (arz *ABCIResponses) Bytes() []byte
Bytes serializes the ABCIResponse using go-amino.
func (*ABCIResponses) ResultsHash ¶
func (arz *ABCIResponses) ResultsHash() []byte
type BlockExecutor ¶
type BlockExecutor struct {
// contains filtered or unexported fields
}
BlockExecutor provides the context and accessories for properly executing a block.
func NewBlockExecutor ¶
func NewBlockExecutor(dbx dbm.DB, db dbm.DB, logger log.Logger, proxyApp proxy.AppConnConsensus, mempool types.Mempool, evpool types.EvidencePool) *BlockExecutor
NewBlockExecutor returns a new BlockExecutor with a NopEventBus. Call SetEventBus to provide one.
func (*BlockExecutor) ApplyBlock ¶
func (blockExec *BlockExecutor) ApplyBlock(s State, blockID types.BlockID, block *types.Block) (State, error)
ApplyBlock validates the block against the state, executes it against the app, fires the relevant events, commits the app, and saves the new state and responses. It's the only function that needs to be called from outside this package to process and commit an entire block. It takes a blockID to avoid recomputing the parts hash.
func (*BlockExecutor) Commit ¶
func (blockExec *BlockExecutor) Commit(block *types.Block) (*abci.ResponseCommit, error)
Commit locks the mempool, runs the ABCI Commit message, and updates the mempool. It returns the result of calling abci.Commit (the AppHash), and an error. The Mempool must be locked during commit and update because state is typically reset on Commit and old txs must be replayed against committed state before new txs are run in the mempool, lest they be invalid.
func (*BlockExecutor) SetEventBus ¶
func (blockExec *BlockExecutor) SetEventBus(eventBus types.BlockEventPublisher)
SetEventBus - sets the event bus for publishing block related events. If not called, it defaults to types.NopEventBus.
func (*BlockExecutor) ValidateBlock ¶
func (blockExec *BlockExecutor) ValidateBlock(s State, block *types.Block) error
ValidateBlock validates the given block against the given state. If the block is invalid, it returns an error. Validation does not mutate state, but does require historical information from the stateDB, ie. to verify evidence from a validator at an old height.
type BlockStoreStateJSON ¶
type BlockStoreStateJSON struct {
Height int64 `json:"height"`
}
func LoadBlockStoreStateJSON ¶
func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON
LoadBlockStoreStateJSON returns the BlockStoreStateJSON as loaded from disk. If no BlockStoreStateJSON was previously persisted, it returns the zero value.
func (BlockStoreStateJSON) Save ¶
func (bsj BlockStoreStateJSON) Save(db dbm.DB)
Save persists the blockStore state to the database as JSON.
type ConsensusParamsInfo ¶
type ConsensusParamsInfo struct { ConsensusParams types.ConsensusParams LastHeightChanged int64 }
ConsensusParamsInfo represents the latest consensus params, or the last height it changed
func (ConsensusParamsInfo) Bytes ¶
func (params ConsensusParamsInfo) Bytes() []byte
Bytes serializes the ConsensusParamsInfo using go-amino.
type ErrAppBlockHeightTooHigh ¶
func (ErrAppBlockHeightTooHigh) Error ¶
func (e ErrAppBlockHeightTooHigh) Error() string
type ErrBlockHashMismatch ¶
func (ErrBlockHashMismatch) Error ¶
func (e ErrBlockHashMismatch) Error() string
type ErrInvalidBlock ¶
type ErrInvalidBlock error
type ErrLastStateMismatch ¶
func (ErrLastStateMismatch) Error ¶
func (e ErrLastStateMismatch) Error() string
type ErrNoABCIResponsesForHeight ¶
type ErrNoABCIResponsesForHeight struct {
Height int64
}
func (ErrNoABCIResponsesForHeight) Error ¶
func (e ErrNoABCIResponsesForHeight) Error() string
type ErrNoABCITxResponseForTxHash ¶
type ErrNoABCITxResponseForTxHash struct {
TxHash []byte
}
func (ErrNoABCITxResponseForTxHash) Error ¶
func (e ErrNoABCITxResponseForTxHash) Error() string
type ErrNoConsensusParamsForHeight ¶
type ErrNoConsensusParamsForHeight struct {
Height int64
}
func (ErrNoConsensusParamsForHeight) Error ¶
func (e ErrNoConsensusParamsForHeight) Error() string
type ErrNoLastQueueHashForQueueID ¶
type ErrNoLastQueueHashForQueueID struct {
QueueID string
}
func (ErrNoLastQueueHashForQueueID) Error ¶
func (e ErrNoLastQueueHashForQueueID) Error() string
type ErrNoLastQueueHeightForQueueID ¶
type ErrNoLastQueueHeightForQueueID struct {
QueueID string
}
func (ErrNoLastQueueHeightForQueueID) Error ¶
func (e ErrNoLastQueueHeightForQueueID) Error() string
type ErrNoValSetForHeight ¶
type ErrNoValSetForHeight struct {
Height int64
}
func (ErrNoValSetForHeight) Error ¶
func (e ErrNoValSetForHeight) Error() string
type ErrProxyAppConn ¶
type ErrProxyAppConn error
type ErrStateMismatch ¶
func (ErrStateMismatch) Error ¶
func (e ErrStateMismatch) Error() string
type ErrUnknownBlock ¶
type ErrUnknownBlock struct {
Height int64
}
func (ErrUnknownBlock) Error ¶
func (e ErrUnknownBlock) Error() string
type SetTdmConfig ¶
type State ¶
type State struct { // Immutable ChainID string // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) LastBlockHeight int64 LastBlockTotalTx int64 LastBlockID types.BlockID LastBlockTime time.Time LastFee uint64 LastAllocation []abci.Allocation // LastValidators is used to validate block.LastCommit. // Validators are persisted to the database separately every time they change, // so we can query for historical validator sets. // Note that if s.LastBlockHeight causes a valset change, // we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 Validators *types.ValidatorSet LastValidators *types.ValidatorSet LastHeightValidatorsChanged int64 // Consensus parameters used for validating blocks. // Changes returned by EndBlock and updated after Commit. ConsensusParams types.ConsensusParams LastHeightConsensusParamsChanged int64 // Merkle root of the results from executing prev block LastResultsHash []byte // The latest AppHash we've received from calling abci.Commit() LastAppHash []byte LastTxsHashList [][]byte // added 24 May 2019 LastMining *int64 // add 26 Mar. 2019 ChainVersion int64 // added 17 Sep. 2019 LastQueueChains *ibc.QueueChain }
State is a short description of the latest committed block of the Tendermint consensus. It keeps all information necessary to validate new blocks, including the last validator set and the consensus params. All fields are exposed so the struct can be easily serialized, but none of them should be mutated directly. Instead, use state.Copy() or state.NextState(...). NOTE: not goroutine-safe.
func LoadLastState ¶
LoadLastState load the last height state from th database.
func LoadStateFromDBOrGenesisDoc ¶
func LoadStateFromDBOrGenesisDoc(stateDBx dbm.DB, stateDB dbm.DB, genesisDoc *types.GenesisDoc) (State, error)
LoadStateFromDBOrGenesisDoc loads the most recent state from the database, or creates a new one from the given genesisDoc and persists the result to the database.
func LoadStateFromDBOrGenesisFile ¶
LoadStateFromDBOrGenesisFile loads the most recent state from the database, or creates a new one from the given genesisFilePath and persists the result to the database.
func MakeGenesisState ¶
func MakeGenesisState(genDoc *types.GenesisDoc) (State, error)
MakeGenesisState creates state from types.GenesisDoc.
func MakeGenesisStateFromFile ¶
MakeGenesisStateFromFile reads and unmarshals state from the given file.
Used during replay and in tests.
func (State) GetValidators ¶
func (s State) GetValidators() (last *types.ValidatorSet, current *types.ValidatorSet)
GetValidators returns the last and current validator sets.
func (State) MakeBlock ¶
func (s State) MakeBlock(height int64, txs []types.Tx, commit *types.Commit, proposer crypto.Address, rewardAddr string, allocation []abci.Allocation, relayer *types.Relayer) (*types.Block, *types.PartSet)
todo 截取apphash MakeBlock builds a block with the given txs and commit from the current state.
type ValidatorsInfo ¶
type ValidatorsInfo struct { ValidatorSet *types.ValidatorSet LastHeightChanged int64 }
ValidatorsInfo represents the latest validator set, or the last height it changed
func (*ValidatorsInfo) Bytes ¶
func (valInfo *ValidatorsInfo) Bytes() []byte
Bytes serializes the ValidatorsInfo using go-amino.