state

package
v0.0.0-...-a4757fd Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: Apache-2.0, Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBranchNameUsed   = errors.New("state db:branch name has been used")
	ErrStateIsNil       = errors.New("the state has no data")
	ErrRevertFromBackup = errors.New("state revert from backup, not find data")
)

Functions

func StateDB

func StateDB(config *viper.Viper) dbm.DB

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

type ErrAppBlockHeightTooHigh struct {
	CoreHeight def.INT
	AppHeight  def.INT
}

func (ErrAppBlockHeightTooHigh) Error

func (e ErrAppBlockHeightTooHigh) Error() string

type ErrBlockHashMismatch

type ErrBlockHashMismatch struct {
	CoreHash []byte
	AppHash  []byte
	Height   def.INT
}

func (ErrBlockHashMismatch) Error

func (e ErrBlockHashMismatch) Error() string

type ErrInvalidBlock

type ErrInvalidBlock error

type ErrLastStateMismatch

type ErrLastStateMismatch struct {
	Height def.INT
	Core   []byte
	App    []byte
}

func (ErrLastStateMismatch) Error

func (e ErrLastStateMismatch) 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 def.INT
}

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

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

func GetState(logger *zap.Logger, config *viper.Viper, stateDB dbm.DB) *State

Load the most recent state from "state" db, or create a new one (and save) from genesis.

func LoadState

func LoadState(logger *zap.Logger, db dbm.DB) *State

func MakeGenesisState

func MakeGenesisState(logger *zap.Logger, db dbm.DB, genDoc *agtypes.GenesisDoc) *State

func MakeGenesisStateFromFile

func MakeGenesisStateFromFile(logger *zap.Logger, db dbm.DB, genDocFile string) *State

func MakeState

func MakeState(logger *zap.Logger, db dbm.DB) *State

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

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

Bytes return go-wired []byte

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

func (s *State) Copy() *State

logger will be copied

func (*State) Equals

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

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 (s *State) FillDataFromPbBytes(pbbys []byte) error

func (*State) GetChainID

func (s *State) GetChainID() string

func (*State) GetLastBlockInfo

func (s *State) GetLastBlockInfo() (pbtypes.BlockID, def.INT, def.INT)

func (*State) GetValidators

func (s *State) GetValidators() (*agtypes.ValidatorSet, *agtypes.ValidatorSet)

func (*State) LoadIntermediate

func (s *State) LoadIntermediate() error

Load the intermediate state into the current state and do some sanity checks

func (*State) PbBytes

func (s *State) PbBytes() ([]byte, error)

func (*State) Save

func (s *State) Save()

func (*State) SaveIntermediate

func (s *State) SaveIntermediate()

func (*State) SaveToKey

func (s *State) SaveToKey(key []byte)

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

func (s *State) SetLogger(logger *zap.Logger)

func (*State) SetValSetLoader

func (s *State) SetValSetLoader(f agtypes.ValSetLoaderFunc)

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 (st *StateTool) BackupLastState(branchName string) error

func (*StateTool) ChangeToIntermidiate

func (st *StateTool) ChangeToIntermidiate()

func (*StateTool) DelBackup

func (st *StateTool) DelBackup(branchName string)

func (*StateTool) Init

func (st *StateTool) Init(config *cfg.Viper) error

func (*StateTool) LastHeight

func (st *StateTool) LastHeight() def.INT

func (*StateTool) RevertFromBackup

func (st *StateTool) RevertFromBackup(branchName string) error

func (*StateTool) SaveNewState

func (st *StateTool) SaveNewState(lastBlock *pbtypes.Block, lastBlockMeta *pbtypes.BlockMeta, lastBlockID *pbtypes.BlockID) error

back to height of lastBlock

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

Jump to

Keyboard shortcuts

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