Documentation ¶
Index ¶
- Constants
- Variables
- func GetDelegates(header *types.Header, snap *ebakusdb.Snapshot, maxWitnesses uint64, ...) vm.WitnessArray
- func RLP(header *types.Header) []byte
- type API
- type DPOS
- func (d *DPOS) APIs(chain consensus.ChainReader) []rpc.API
- func (d *DPOS) AccumulateRewards(config *params.DPOSConfig, state *state.StateDB, header *types.Header, ...)
- func (d *DPOS) Author(header *types.Header) (common.Address, error)
- func (d *DPOS) Authorize(signer common.Address, signFn SignerFn)
- func (d *DPOS) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (d *DPOS) Close() error
- func (d *DPOS) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...)
- func (d *DPOS) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (d *DPOS) Prepare(chain consensus.ChainReader, stop <-chan struct{}) (*types.Block, *types.Header, error)
- func (d *DPOS) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, ...) error
- func (d *DPOS) SealHash(header *types.Header) (hash common.Hash)
- func (d *DPOS) SetBlockchain(bc *core.BlockChain)
- func (d *DPOS) VerifyBlock(chain consensus.ChainReader, block *types.Block) error
- func (d *DPOS) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (d *DPOS) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (d *DPOS) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- type SignerFn
- type State
- type Witness
- type WitnessArray
Constants ¶
const ( // The account wants to be witness and will be considered for block producer // by stake delegation ElectEnabledFlag uint64 = 1 )
Variables ¶
var ( // ErrInvalidTimestamp is returned if the timestamp of a block is lower than // the previous block's timestamp + the minimum block period. ErrInvalidTimestamp = errors.New("invalid timestamp") ErrInvalidDelegateUpdateBlock = errors.New("Delegates updated at wrong block") // ErrProductionAborted is returned when the producer is instructed to prepaturely abort ErrProductionAborted = errors.New("Production aborted") )
Functions ¶
func GetDelegates ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to allow controlling the voting mechanisms of the delegeted proof-of-stake scheme.
func (*API) GetBlockDensity ¶
func (*API) GetDelegates ¶
GetDelegates retrieves the list of delegates at the specified block.
type DPOS ¶
type DPOS struct {
// contains filtered or unexported fields
}
DPOS is the delegate proof-of-stake consensus engine
func New ¶
func New(config *params.DPOSConfig, db ethdb.Database, ebakusDb *ebakusdb.DB, genesis *core.Genesis) *DPOS
New creates a Delegated Proof of Stake consensus engine
func (*DPOS) APIs ¶
func (d *DPOS) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the delegate voting etc.
func (*DPOS) AccumulateRewards ¶
func (d *DPOS) AccumulateRewards(config *params.DPOSConfig, state *state.StateDB, header *types.Header, coinbase common.Address)
AccumulateRewards credits the coinbase of the given block with the reward
func (*DPOS) Author ¶
Author implements consensus.Engine, returning the Ebakus address recovered from the signature in the header
func (*DPOS) Authorize ¶
Authorize injects a private key into the consensus engine to mint new blocks with.
func (*DPOS) CalcDifficulty ¶
func (d *DPOS) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
CalcDifficulty is essentialy dummy in ebakus
func (*DPOS) Close ¶
Close terminates any background threads maintained by the consensus engine (we don't have any).
func (*DPOS) Finalize ¶
func (d *DPOS) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ebakusState *ebakusdb.Snapshot, coinbase common.Address, txs []*types.Transaction)
Finalize runs any post-transaction state modifications (e.g. block rewards) and assembles the final block. Note: The block header and state database might be updated to reflect any consensus rules that happen at finalization (e.g. block rewards).
func (*DPOS) FinalizeAndAssemble ¶
func (d *DPOS) FinalizeAndAssemble(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ebakusState *ebakusdb.Snapshot, coinbase common.Address, txs []*types.Transaction, receipts []*types.Receipt) (*types.Block, error)
FinalizeAndAssemble implements consensus.Engine, accumulating the block and setting the final state and assembling the block.
func (*DPOS) Prepare ¶
func (d *DPOS) Prepare(chain consensus.ChainReader, stop <-chan struct{}) (*types.Block, *types.Header, error)
Prepare initializes the consensus fields of a block header according to the rules of a particular engine. The changes are executed inline.
func (*DPOS) Seal ¶
func (d *DPOS) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal generates a new block for the given input block with the local miner's seal place on top.
func (*DPOS) SetBlockchain ¶
func (d *DPOS) SetBlockchain(bc *core.BlockChain)
func (*DPOS) VerifyBlock ¶
VerifyBlock verifies that the given block conform to the consensus rules of a given engine.
func (*DPOS) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules of a given engine. Verifying the seal may be done optionally here, or explicitly via the VerifySeal method.
func (*DPOS) VerifyHeaders ¶
func (d *DPOS) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications (the order is that of the input slice).
func (*DPOS) VerifySeal ¶
VerifySeal checks whether the crypto seal on a header is valid according to the consensus rules of the given engine.
type SignerFn ¶
SignerFn is a signer callback function to request a hash to be signed by a backing account.
type State ¶
type State struct { BlockNum uint64 Hash common.Hash Witnesses map[common.Address]*Witness // contains filtered or unexported fields }
State holds the information for the current delegate sealing procedure at a specific point in time
type WitnessArray ¶
type WitnessArray []*Witness
func (WitnessArray) Diff ¶
func (s WitnessArray) Diff(b WitnessArray) types.DelegateDiff
func (WitnessArray) Len ¶
func (s WitnessArray) Len() int
func (WitnessArray) Less ¶
func (s WitnessArray) Less(i, j int) bool
func (WitnessArray) Swap ¶
func (s WitnessArray) Swap(i, j int)