Documentation ¶
Index ¶
- Variables
- type API
- func (api *API) GetAllMessage() []types.ConsensusMsg
- func (api *API) GetCommitMsgs() []*types.CommitMsg
- func (api *API) GetCurrentHeight() *big.Int
- func (api *API) GetCurrentRound() uint32
- func (api *API) GetCurrentStep() uint32
- func (api *API) GetPrePrepareMsg() *types.PreprepareMsg
- func (api *API) GetPrepareMsgs() []*types.PrepareMsg
- func (api *API) GetSigners(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error)
- type BftManager
- type Dpos
- func (d *Dpos) APIs(chain consensus.ChainReader) []rpc.API
- 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) CleanOldMsg(h *big.Int)
- func (d *Dpos) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (d *Dpos) GetWitnessesFromStateDB(stateDB *state.StateDB) ([]common.Address, []string)
- func (d *Dpos) HandleBftMsg(chain consensus.ChainReader, msg types.ConsensusMsg)
- func (d *Dpos) InitBft(sendBftMsg func(types.ConsensusMsg), SendPeerUpdate func(urls []string), ...)
- func (d *Dpos) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (d *Dpos) ProducingStop()
- func (d *Dpos) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (d *Dpos) VerifyCommitMsg(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
- func (d *Dpos) VerifyWitnesses(header *types.Header, db *state.StateDB, parent *types.Header) error
- type Manager
- type SignerFn
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to allow controlling the signer and voting mechanisms of the proof-of-authority scheme.
func (*API) GetAllMessage ¶
func (api *API) GetAllMessage() []types.ConsensusMsg
func (*API) GetCommitMsgs ¶
func (*API) GetCurrentHeight ¶
func (*API) GetCurrentRound ¶
func (*API) GetCurrentStep ¶
func (*API) GetPrePrepareMsg ¶
func (api *API) GetPrePrepareMsg() *types.PreprepareMsg
func (*API) GetPrepareMsgs ¶
func (api *API) GetPrepareMsgs() []*types.PrepareMsg
func (*API) GetSigners ¶
GetSigners retrieves the list of authorized signers at the specified block.
type BftManager ¶
type BftManager struct {
// contains filtered or unexported fields
}
func (*BftManager) VerifyCmtMsgOf ¶
func (bft *BftManager) VerifyCmtMsgOf(block *types.Block) error
type Dpos ¶
type Dpos struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *params.DposConfig, db vntdb.Database) *Dpos
New creates a Delegated proof-of-stake consensus engine with the initial signers set to the ones provided by the user.
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 signer voting.
func (*Dpos) Author ¶
Author implements consensus.Engine, returning the VNT address recovered from the signature in the header's extra-data section.
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 the difficulty adjustment algorithm. It returns the difficulty that a new block should have based on the previous blocks in the chain and the current signer.
func (*Dpos) CleanOldMsg ¶
func (*Dpos) Finalize ¶
func (d *Dpos) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, receipts []*types.Receipt) (*types.Block, error)
Finalize implements consensus.Engine, grants reward and returns the final block.
func (*Dpos) GetWitnessesFromStateDB ¶
GetWitnessesFromStateDB Get the first N candidates as witnesses from stateDB It's can be used for get produce block and verify witnesses
func (*Dpos) HandleBftMsg ¶
func (d *Dpos) HandleBftMsg(chain consensus.ChainReader, msg types.ConsensusMsg)
HandleBftMsg handle the bft message received from peer.
func (*Dpos) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*Dpos) ProducingStop ¶
func (d *Dpos) ProducingStop()
func (*Dpos) Seal ¶
func (d *Dpos) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
Seal implements consensus.Engine, attempting to create a sealed block using the local signing credentials.
func (*Dpos) VerifyHeader ¶
VerifyHeader checks whether a header conforms to the consensus rules.
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. 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 implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
type Manager ¶
type Manager struct { Witnesses []common.Address // Witness list, all current witness // contains filtered or unexported fields }
Manager is used to judge weather a witness is block producer or not. - Check weather a witness is block producer or not - Check weather a witness is in witness list