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 GetState(logger *zap.Logger, config *viper.Viper, stateDB dbm.DB) *State
- func LoadState(logger *zap.Logger, db dbm.DB) *State
- func MakeGenesisState(logger *zap.Logger, db dbm.DB, genDoc *agtypes.GenesisDoc) *State
- func MakeGenesisStateFromFile(logger *zap.Logger, db dbm.DB, genDocFile string) *State
- func MakeState(logger *zap.Logger, db dbm.DB) *State
- func (s *State) ApplyBlock(eventSwitch agtypes.EventSwitch, block *agtypes.BlockCache, ...) error
- func (s *State) Bytes() []byte
- func (s *State) CommitStateUpdateMempool(eventSwitch agtypes.EventSwitch, block *agtypes.BlockCache, ...) error
- func (s *State) Copy() *State
- func (s *State) Equals(s2 *State) bool
- func (s *State) ExecBlock(eventSwitch agtypes.EventSwitch, block *agtypes.BlockCache, ...) error
- func (s *State) FillDataFromPbBytes(pbbys []byte) error
- func (s *State) GetChainID() string
- func (s *State) GetLastBlockInfo() (pbtypes.BlockID, def.INT, def.INT)
- func (s *State) GetValidators() (*agtypes.ValidatorSet, *agtypes.ValidatorSet)
- func (s *State) LoadIntermediate() error
- func (s *State) PbBytes() ([]byte, error)
- func (s *State) Save()
- func (s *State) SaveIntermediate()
- func (s *State) SaveToKey(key []byte)
- func (s *State) SetBlockAndValidators(header *pbtypes.Header, blockPartsHeader *pbtypes.PartSetHeader, ...)
- func (s *State) SetBlockExecutable(ex IBlockExecutable)
- func (s *State) SetLogger(logger *zap.Logger)
- func (s *State) ValidateBlock(block *agtypes.BlockCache) 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() def.INT
- func (st *StateTool) RevertFromBackup(branchName string) error
- func (st *StateTool) SaveNewState(lastBlock *pbtypes.Block, lastBlockMeta *pbtypes.BlockMeta, ...) error
- type TPSCalculator
Constants ¶
This section is empty.
Variables ¶
Functions ¶
Types ¶
type BlockStore ¶
type BlockStore interface { Height() def.INT LoadBlock(height def.INT) *agtypes.BlockCache LoadBlockMeta(height def.INT) *pbtypes.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 ¶
func (ErrUnknownBlock) Error ¶
func (e ErrUnknownBlock) Error() string
type Handshaker ¶
type Handshaker struct {
// contains filtered or unexported fields
}
func NewHandshaker ¶
func NewHandshaker(config *viper.Viper, 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(*agtypes.BlockCache, events.Fireable, *pbtypes.PartSetHeader) ExecBlock(*agtypes.BlockCache, events.Fireable, *agtypes.ExecuteResult) EndBlock(*agtypes.BlockCache, events.Fireable, *pbtypes.PartSetHeader, []*agtypes.ValidatorAttr, *agtypes.ValidatorSet) }
type State ¶
type State struct { // should not change GenesisDoc *agtypes.GenesisDoc ChainID string // updated at end of ExecBlock LastBlockHeight def.INT // Genesis state has this set to 0. So, Block(H=0) does not exist. LastBlockID pbtypes.BlockID LastBlockTime def.INT Validators *agtypes.ValidatorSet LastValidators *agtypes.ValidatorSet // block.LastCommit validated against this LastNonEmptyHeight def.INT // 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 (*State) ApplyBlock ¶
func (s *State) ApplyBlock(eventSwitch agtypes.EventSwitch, block *agtypes.BlockCache, partsHeader *pbtypes.PartSetHeader, mempool agtypes.IMempool, round def.INT) error
ApplyBlock executes the block, then commits and updates the mempool atomically
func (*State) CommitStateUpdateMempool ¶
func (s *State) CommitStateUpdateMempool(eventSwitch agtypes.EventSwitch, block *agtypes.BlockCache, mempool agtypes.IMempool, round def.INT) 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 agtypes.EventSwitch, block *agtypes.BlockCache, blockPartsHeader *pbtypes.PartSetHeader, round def.INT) error
Execute the block to mutate State. Validates block and then executes Data.Txs in the block.
func (*State) FillDataFromPbBytes ¶
func (*State) GetChainID ¶
func (*State) GetLastBlockInfo ¶
func (*State) GetValidators ¶
func (s *State) GetValidators() (*agtypes.ValidatorSet, *agtypes.ValidatorSet)
func (*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 *pbtypes.Header, blockPartsHeader *pbtypes.PartSetHeader, prevValSet, nextValSet *agtypes.ValidatorSet)
Mutate state variables to match block and validators after running EndBlock
func (*State) SetBlockExecutable ¶
func (s *State) SetBlockExecutable(ex IBlockExecutable)
func (*State) ValidateBlock ¶
func (s *State) ValidateBlock(block *agtypes.BlockCache) error
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