Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IAPI ¶
type IAPI interface {
APIs(chain IChainReader) []rpc.API
}
IAPI returns the RPC APIs this consensus engine provides.
type IChainReader ¶
type IChainReader interface { // Config retrieves the blockchain's chain configuration. Config() *params.ChainConfig // CurrentHeader retrieves the current header from the local chain. CurrentHeader() *types.Header // GetHeaderByNumber retrieves a block header from the database by number. GetHeaderByNumber(number uint64) *types.Header // GetHeaderByHash retrieves a block header from the database by its hash. GetHeaderByHash(hash common.Hash) *types.Header // GetHeader retrieves a block header from the database by hash and number. GetHeader(hash common.Hash, number uint64) *types.Header // GetBlock retrieves a block from the database by hash and number. GetBlock(hash common.Hash, number uint64) *types.Block // StateAt retrieves a block state from the database by hash. StateAt(hash common.Hash) (*state.StateDB, error) // WriteBlockWithState writes the block and all associated state to the database. WriteBlockWithState(block *types.Block, receipts []*types.Receipt, state *state.StateDB) (bool, error) // CalcGasLimit computes the gas limit of the next block after parent. CalcGasLimit(parent *types.Block) uint64 // HasBlockAndState checks if a block and associated state trie is fully present // in the database or not, caching it if present. HasBlockAndState(hash common.Hash, number uint64) bool // HasBlock checks if a block is fully present in the database or not. HasBlock(hash common.Hash, number uint64) bool // FillForkID fills the current and next forkID FillForkID(header *types.Header, statedb *state.StateDB) error // ForkUpdate checks and records the fork information ForkUpdate(block *types.Block, statedb *state.StateDB) error }
IChainReader defines a small collection of methods needed to access the local blockchain.
type IConsensus ¶
type IConsensus interface { IChainReader IEngine ITxProcessor ITxPool }
IConsensus defines a small collection of methods needed for miner.
type IEngine ¶
type IEngine interface { // Author retrieves the name of the account that minted the given block Author(header *types.Header) (common.Name, error) // Prepare initializes the consensus fields of a block header according to the rules of a particular engine. The changes are executed inline. Prepare(chain IChainReader, header *types.Header, txs []*types.Transaction, receipts []*types.Receipt, state *state.StateDB) error // Finalize assembles the final block. Finalize(chain IChainReader, header *types.Header, txs []*types.Transaction, receipts []*types.Receipt, state *state.StateDB) (*types.Block, error) // Seal generates a new block for the given input block with the local miner's seal place on top. Seal(chain IChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error) Engine() IEngine ProcessAction(number uint64, chainCfg *params.ChainConfig, state *state.StateDB, action *types.Action) ([]*types.InternalAction, error) GetDelegatedByTime(state *state.StateDB, candidate string, timestamp uint64) (stake *big.Int, err error) GetLatestEpoch(state *state.StateDB) (epoch uint64, err error) GetPrevEpoch(state *state.StateDB, epoch uint64) (pecho uint64, err error) GetNextEpoch(state *state.StateDB, epoch uint64) (necho uint64, err error) GetActivedCandidateSize(state *state.StateDB, epoch uint64) (size uint64, err error) GetActivedCandidate(state *state.StateDB, epoch uint64, index uint64) (name string, stake *big.Int, totalVote *big.Int, counter uint64, actualCounter uint64, replace uint64, err error) GetCandidateStake(state *state.StateDB, epoch uint64, candidate string) (stake *big.Int, err error) GetVoterStake(state *state.StateDB, epoch uint64, voter string, candidate string) (stake *big.Int, err error) IAPI IValidator }
IEngine is an algorithm agnostic consensus engine.
type ITxPool ¶
type ITxPool interface {
Pending() (map[common.Name][]*types.Transaction, error)
}
ITxPool contains all currently known transactions.
type ITxProcessor ¶
type ITxProcessor interface { // ApplyTransaction attempts to apply a transaction. ApplyTransaction(coinbase *common.Name, gp *common.GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, cfg vm.Config) (*types.Receipt, uint64, error) }
ITxProcessor is an Processor.
type IValidator ¶ added in v0.0.16
type IValidator interface { // CalcDifficulty is the difficulty adjustment algorithm. It returns the difficulty // that a new block should have. CalcDifficulty(chain IChainReader, time uint64, parent *types.Header) *big.Int // VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine. VerifySeal(chain IChainReader, header *types.Header) error }
IValidator implements consensus validator.
Click to show internal directories.
Click to hide internal directories.