state

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCommitBlock

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

func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error)

MakeGenesisDocFromFile reads and unmarshals genesis doc from the given file.

Types

type ABCIResponses

type ABCIResponses struct {
	Height int64

	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

func NewABCIResponses(block *types.Block) *ABCIResponses

NewABCIResponses returns a new ABCIResponses

func (*ABCIResponses) Bytes

func (a *ABCIResponses) Bytes() []byte

Bytes serializes the ABCIResponse using go-wire

type ErrAppBlockHeightTooHigh

type ErrAppBlockHeightTooHigh struct {
	CoreHeight int64
	AppHeight  int64
}

func (ErrAppBlockHeightTooHigh) Error

func (e ErrAppBlockHeightTooHigh) Error() string

type ErrBlockHashMismatch

type ErrBlockHashMismatch struct {
	CoreHash []byte
	AppHash  []byte
	Height   int64
}

func (ErrBlockHashMismatch) Error

func (e ErrBlockHashMismatch) Error() string

type ErrInvalidBlock

type ErrInvalidBlock error

type ErrLastStateMismatch

type ErrLastStateMismatch struct {
	Height int64
	Core   []byte
	App    []byte
}

func (ErrLastStateMismatch) Error

func (e ErrLastStateMismatch) Error() string

type ErrNoValSetForHeight

type ErrNoValSetForHeight struct {
	Height int64
}

func (ErrNoValSetForHeight) Error

func (e ErrNoValSetForHeight) Error() string

type ErrProxyAppConn

type ErrProxyAppConn error

type ErrStateMismatch

type ErrStateMismatch struct {
	Got      *State
	Expected *State
}

func (ErrStateMismatch) Error

func (e ErrStateMismatch) Error() string

type ErrUnknownBlock

type ErrUnknownBlock struct {
	Height int64
}

func (ErrUnknownBlock) Error

func (e ErrUnknownBlock) Error() string

type State

type State struct {
	ChainID string
	// Consensus parameters used for validating blocks
	Params types.ConsensusParams

	// 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 int64
	LastBlockID     types.BlockID
	LastBlockTime   time.Time
	Validators      *types.ValidatorSet
	LastValidators  *types.ValidatorSet
	// 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 int64

	// AppHash is updated after Commit
	AppHash []byte
	// 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.8.0

func GetState(stateDB dbm.DB, genesisFile string) (*State, error)

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 LoadState

func LoadState(db dbm.DB) *State

LoadState loads the State from the database.

func MakeGenesisState

func MakeGenesisState(db dbm.DB, genDoc *types.GenesisDoc) (*State, error)

MakeGenesisState creates state from types.GenesisDoc.

func MakeGenesisStateFromFile

func MakeGenesisStateFromFile(db dbm.DB, genDocFile string) (*State, error)

MakeGenesisStateFromFile reads and unmarshals state from the given file.

Used during replay and in tests.

func (*State) ApplyBlock added in v0.8.0

func (s *State) ApplyBlock(txEventPublisher types.TxEventPublisher, 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) Bytes

func (s *State) Bytes() []byte

Bytes serializes the State using go-wire.

func (*State) CommitStateUpdateMempool added in v0.8.0

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) Copy

func (s *State) Copy() *State

Copy makes a copy of the State for mutating.

func (*State) Equals

func (s *State) Equals(s2 *State) bool

Equals returns true if the States are identical.

func (*State) GetValidators added in v0.8.0

func (s *State) GetValidators() (last *types.ValidatorSet, current *types.ValidatorSet)

GetValidators returns the last and current validator sets.

func (*State) LoadABCIResponses added in v0.9.1

func (s *State) LoadABCIResponses() *ABCIResponses

LoadABCIResponses loads the ABCIResponses from the database. This is useful for recovering from crashes where we called app.Commit and before we called s.Save()

func (*State) LoadValidators added in v0.11.0

func (s *State) LoadValidators(height int64) (*types.ValidatorSet, error)

LoadValidators loads the ValidatorSet for a given height.

func (*State) Save added in v0.7.0

func (s *State) Save()

Save persists the State to the database.

func (*State) SaveABCIResponses added in v0.9.1

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.8.0

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) SetLogger added in v0.10.0

func (s *State) SetLogger(l log.Logger)

SetLogger sets the logger on the State.

func (*State) ValExecBlock added in v0.9.1

func (s *State) ValExecBlock(txEventPublisher types.TxEventPublisher, 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

func (*State) ValidateBlock added in v0.7.0

func (s *State) ValidateBlock(block *types.Block) error

ValidateBlock validates the block against the 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-wire

Directories

Path Synopsis
kv

Jump to

Keyboard shortcuts

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