Documentation ¶
Index ¶
- Variables
- func StateDB(config *viper.Viper) dbm.DB
- type BlockStore
- type ErrAppBlockHeightTooHigh
- type ErrBlockHashMismatch
- type ErrInvalidBlock
- type ErrLastStateMismatch
- type ErrProxyAppConn
- type ErrStateMismatch
- type ErrUnknownBlock
- type Handshaker
- type IBlockExecutable
- type State
- func (s *State) ApplyBlock(eventSwitch types.EventSwitch, block *types.Block, ...) error
- func (s *State) Bytes() []byte
- func (s *State) CheckPubkeyPtr()
- func (s *State) CommitStateUpdateMempool(eventSwitch types.EventSwitch, block *types.Block, mempool types.IMempool, ...) error
- func (s *State) Copy() *State
- func (s *State) Equals(s2 *State) bool
- func (s *State) ExecBlock(eventSwitch types.EventSwitch, block *types.Block, ...) error
- func (s *State) GetChainID() string
- func (s *State) GetLastBlockInfo() (types.BlockID, int64, time.Time)
- func (s *State) GetValidators() (*types.ValidatorSet, *types.ValidatorSet)
- func (s *State) LoadIntermediate()
- func (s *State) Save()
- func (s *State) SaveIntermediate()
- func (s *State) SaveToKey(key []byte)
- func (s *State) SetBlockAndValidators(header *types.Header, blockPartsHeader types.PartSetHeader, ...)
- func (s *State) SetBlockExecutable(ex IBlockExecutable)
- func (s *State) ValidateBlock(block *types.Block) error
- type StateTool
- func (st *StateTool) BackupLastState(branchName string) error
- func (st *StateTool) ChangeToIntermidiate()
- func (st *StateTool) DelBackup(branchName string)
- func (st *StateTool) Init(config *cfg.Viper) error
- func (st *StateTool) LastHeight() int64
- func (st *StateTool) NewValSet(lastHeight int64) *types.ValidatorSet
- func (st *StateTool) RevertFromBackup(branchName string) error
- func (st *StateTool) SaveNewState(valSet *types.ValidatorSet, nextBlock, lastBlock *types.Block, ...) error
- type TPSCalculator
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type BlockStore ¶
type BlockStore interface { Height() int LoadBlock(height int) *types.Block LoadBlockMeta(height int) *types.BlockMeta }
TODO: Should we move blockchain/store.go to its own package?
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 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 Handshaker ¶
type Handshaker struct {
// contains filtered or unexported fields
}
func NewHandshaker ¶
func NewHandshaker(config cfg.Config, state *State, store BlockStore) *Handshaker
func (*Handshaker) Handshake ¶
func (h *Handshaker) Handshake() error
TODO: retry the handshake/replay if it fails ?
type IBlockExecutable ¶
type IBlockExecutable interface { BeginBlock(*types.Block, events.Fireable, *types.PartSetHeader) error ExecBlock(*types.Block, events.Fireable, *types.ExecuteResult) error EndBlock(*types.Block, events.Fireable, *types.PartSetHeader, []*types.ValidatorAttr, *types.ValidatorSet) error }
type State ¶
type State struct { // should not change GenesisDoc *types.GenesisDoc ChainID string // updated at end of ExecBlock LastBlockHeight int64 // Genesis state has this set to 0. So, Block(H=0) does not exist. LastBlockID types.BlockID LastBlockTime time.Time Validators *types.ValidatorSet LastValidators *types.ValidatorSet // block.LastCommit validated against this LastNonEmptyHeight int64 // AppHash is updated after Commit AppHash []byte // ReceiptsHash is updated only after eval the txs ReceiptsHash []byte // contains filtered or unexported fields }
NOTE: not goroutine-safe.
func GetState ¶
Load the most recent state from "state" db, or create a new one (and save) from genesis.
func MakeGenesisState ¶
func MakeGenesisState(db dbm.DB, genDoc *types.GenesisDoc) *State
func (*State) ApplyBlock ¶
func (s *State) ApplyBlock(eventSwitch types.EventSwitch, block *types.Block, partsHeader types.PartSetHeader, mempool types.IMempool, round int64) error
ApplyBlock executes the block, then commits and updates the mempool atomically
func (*State) CheckPubkeyPtr ¶
func (s *State) CheckPubkeyPtr()
func (*State) CommitStateUpdateMempool ¶
func (s *State) CommitStateUpdateMempool(eventSwitch types.EventSwitch, block *types.Block, mempool types.IMempool, round int64) error
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) ExecBlock ¶
func (s *State) ExecBlock(eventSwitch types.EventSwitch, block *types.Block, blockPartsHeader types.PartSetHeader, round int64) error
Execute the block to mutate State. Validates block and then executes Data.Txs in the block.
func (*State) GetChainID ¶
func (*State) GetLastBlockInfo ¶
func (*State) GetValidators ¶
func (s *State) GetValidators() (*types.ValidatorSet, *types.ValidatorSet)
func (*State) LoadIntermediate ¶
func (s *State) LoadIntermediate()
Load the intermediate state into the current state and do some sanity checks
func (*State) SaveIntermediate ¶
func (s *State) SaveIntermediate()
func (*State) SetBlockAndValidators ¶
func (s *State) SetBlockAndValidators(header *types.Header, blockPartsHeader types.PartSetHeader, prevValSet, nextValSet *types.ValidatorSet)
Mutate state variables to match block and validators after running EndBlock
func (*State) SetBlockExecutable ¶
func (s *State) SetBlockExecutable(ex IBlockExecutable)
type StateTool ¶
type StateTool struct {
// contains filtered or unexported fields
}
func (*StateTool) BackupLastState ¶
func (*StateTool) ChangeToIntermidiate ¶
func (st *StateTool) ChangeToIntermidiate()
func (*StateTool) LastHeight ¶
func (*StateTool) RevertFromBackup ¶
type TPSCalculator ¶
type TPSCalculator struct {
// contains filtered or unexported fields
}
func NewTPSCalculator ¶
func NewTPSCalculator(count uint32) *TPSCalculator
func (*TPSCalculator) AddRecord ¶
func (c *TPSCalculator) AddRecord(txExcuted uint32)
func (*TPSCalculator) TPS ¶
func (c *TPSCalculator) TPS() int