Documentation ¶
Index ¶
- func ExecCommitBlock(appConnConsensus proxy.AppConnConsensus, block *types.Block, logger log.Logger) ([]byte, error)
- func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error)
- type ABCIResponses
- type ErrAppBlockHeightTooHigh
- type ErrBlockHashMismatch
- type ErrInvalidBlock
- type ErrLastStateMismatch
- type ErrNoValSetForHeight
- type ErrProxyAppConn
- type ErrStateMismatch
- type ErrUnknownBlock
- type State
- func (s *State) ApplyBlock(eventCache types.Fireable, proxyAppConn proxy.AppConnConsensus, ...) error
- func (s *State) Bytes() []byte
- func (s *State) CommitStateUpdateMempool(proxyAppConn proxy.AppConnConsensus, block *types.Block, mempool types.Mempool) error
- func (s *State) Copy() *State
- func (s *State) Equals(s2 *State) bool
- func (s *State) GetValidators() (*types.ValidatorSet, *types.ValidatorSet)
- func (s *State) LoadABCIResponses() *ABCIResponses
- func (s *State) LoadValidators(height int) (*types.ValidatorSet, error)
- func (s *State) Params() types.ConsensusParams
- func (s *State) Save()
- func (s *State) SaveABCIResponses(abciResponses *ABCIResponses)
- func (s *State) SetBlockAndValidators(header *types.Header, blockPartsHeader types.PartSetHeader, ...)
- func (s *State) SetLogger(l log.Logger)
- func (s *State) ValExecBlock(eventCache types.Fireable, proxyAppConn proxy.AppConnConsensus, ...) (*ABCIResponses, error)
- func (s *State) ValidateBlock(block *types.Block) error
- type ValidatorsInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecCommitBlock ¶ added in v0.9.2
func ExecCommitBlock(appConnConsensus proxy.AppConnConsensus, block *types.Block, logger log.Logger) ([]byte, 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 MakeGenesisDocFromFile ¶ added in v0.15.0
func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error)
MakeGenesisDocFromFile reads and unmarshals genesis doc from the given file.
Types ¶
type ABCIResponses ¶ added in v0.9.2
type ABCIResponses struct { Height int DeliverTx []*abci.ResponseDeliverTx EndBlock abci.ResponseEndBlock // contains filtered or unexported fields }
ABCIResponses retains the responses of the various ABCI calls during block processing. It is persisted to disk before calling Commit.
func NewABCIResponses ¶ added in v0.9.2
func NewABCIResponses(block *types.Block) *ABCIResponses
NewABCIResponses returns a new ABCIResponses
func (*ABCIResponses) Bytes ¶ added in v0.9.2
func (a *ABCIResponses) Bytes() []byte
Bytes serializes the ABCIResponse using go-wire
type ErrAppBlockHeightTooHigh ¶ added in v0.9.2
func (ErrAppBlockHeightTooHigh) Error ¶ added in v0.9.2
func (e ErrAppBlockHeightTooHigh) Error() string
type ErrBlockHashMismatch ¶ added in v0.9.2
func (ErrBlockHashMismatch) Error ¶ added in v0.9.2
func (e ErrBlockHashMismatch) Error() string
type ErrInvalidBlock ¶ added in v0.9.2
type ErrInvalidBlock error
type ErrLastStateMismatch ¶ added in v0.9.2
func (ErrLastStateMismatch) Error ¶ added in v0.9.2
func (e ErrLastStateMismatch) Error() string
type ErrNoValSetForHeight ¶ added in v0.15.0
type ErrNoValSetForHeight struct {
Height int
}
func (ErrNoValSetForHeight) Error ¶ added in v0.15.0
func (e ErrNoValSetForHeight) Error() string
type ErrProxyAppConn ¶ added in v0.9.2
type ErrProxyAppConn error
type ErrStateMismatch ¶ added in v0.9.2
func (ErrStateMismatch) Error ¶ added in v0.9.2
func (e ErrStateMismatch) Error() string
type ErrUnknownBlock ¶ added in v0.9.2
type ErrUnknownBlock struct {
Height int
}
func (ErrUnknownBlock) Error ¶ added in v0.9.2
func (e ErrUnknownBlock) Error() string
type State ¶
type State struct { // should not change GenesisDoc *types.GenesisDoc ChainID string // These fields are updated by SetBlockAndValidators. // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) // LastValidators is used to validate block.LastCommit. LastBlockHeight int LastBlockID types.BlockID LastBlockTime time.Time Validators *types.ValidatorSet LastValidators *types.ValidatorSet // AppHash is updated after Commit AppHash []byte TxIndexer txindex.TxIndexer `json:"-"` // Transaction indexer // When a block returns a validator set change via EndBlock, // the change only applies to the next block. // So, if s.LastBlockHeight causes a valset change, // we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 LastHeightValidatorsChanged int // contains filtered or unexported fields }
State represents the latest committed state of the Tendermint consensus, including the last committed block and validator set. Newly committed blocks are validated and executed against the State. NOTE: not goroutine-safe.
func GetState ¶ added in v0.9.2
GetState loads the most recent state from the database, or creates a new one from the given genesisFile and persists the result to the database.
func MakeGenesisStateFromFile ¶
MakeGenesisStateFromFile reads and unmarshals state from the given file.
Used during replay and in tests.
func (*State) ApplyBlock ¶ added in v0.9.2
func (s *State) ApplyBlock(eventCache types.Fireable, proxyAppConn proxy.AppConnConsensus, block *types.Block, partsHeader types.PartSetHeader, mempool types.Mempool) error
ApplyBlock validates the block against the state, executes it against the app, commits it, and saves the block and state. It's the only function that needs to be called from outside this package to process and commit an entire block.
func (*State) CommitStateUpdateMempool ¶ added in v0.9.2
func (s *State) CommitStateUpdateMempool(proxyAppConn proxy.AppConnConsensus, block *types.Block, mempool types.Mempool) error
CommitStateUpdateMempool locks the mempool, runs the ABCI Commit message, and updates the mempool. 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 (*State) GetValidators ¶ added in v0.9.2
func (s *State) GetValidators() (*types.ValidatorSet, *types.ValidatorSet)
GetValidators returns the last and current validator sets.
func (*State) LoadABCIResponses ¶ added in v0.9.2
func (s *State) LoadABCIResponses() *ABCIResponses
LoadABCIResponses loads the ABCIResponses from the database.
func (*State) LoadValidators ¶
func (s *State) LoadValidators(height int) (*types.ValidatorSet, error)
LoadValidators loads the ValidatorSet for a given height.
func (*State) Params ¶
func (s *State) Params() types.ConsensusParams
Params returns the consensus parameters used for validating blocks
func (*State) SaveABCIResponses ¶ added in v0.9.2
func (s *State) SaveABCIResponses(abciResponses *ABCIResponses)
SaveABCIResponses persists the ABCIResponses to the database. This is useful in case we crash after app.Commit and before s.Save().
func (*State) SetBlockAndValidators ¶ added in v0.9.2
func (s *State) SetBlockAndValidators(header *types.Header, blockPartsHeader types.PartSetHeader, abciResponses *ABCIResponses)
SetBlockAndValidators mutates State variables to update block and validators after running EndBlock.
func (*State) ValExecBlock ¶ added in v0.9.2
func (s *State) ValExecBlock(eventCache types.Fireable, proxyAppConn proxy.AppConnConsensus, block *types.Block) (*ABCIResponses, error)
ValExecBlock executes the block, but does NOT mutate State. + validates the block + executes block.Txs on the proxyAppConn
type ValidatorsInfo ¶ added in v0.15.0
type ValidatorsInfo struct { ValidatorSet *types.ValidatorSet LastHeightChanged int }
ValidatorsInfo represents the latest validator set, or the last time it changed
func (*ValidatorsInfo) Bytes ¶ added in v0.15.0
func (vi *ValidatorsInfo) Bytes() []byte
Bytes serializes the ValidatorsInfo using go-wire