Documentation ¶
Overview ¶
Package devote implements the proof-of-authority consensus engine.
Package devote implements the proof-of-stake consensus engine.
Index ¶
- Variables
- func AccumulateRewards(govAddress common.Address, state *state.StateDB, header *types.Header, ...)
- func NextSlot(now uint64) uint64
- func PrevSlot(now uint64) uint64
- type API
- func (api *API) Discard(signer string)
- func (api *API) GetConfirmedBlockNumber() (*big.Int, error)
- func (api *API) GetSigners(number *rpc.BlockNumber) ([]string, error)
- func (api *API) GetSignersAtHash(hash common.Hash) ([]string, error)
- func (api *API) GetSignersByEpoch(epoch uint64) ([]string, error)
- func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
- func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error)
- func (api *API) Proposals() map[string]bool
- func (api *API) Propose(signer string, auth bool)
- type Devote
- func (d *Devote) APIs(chain consensus.ChainReader) []rpc.API
- func (d *Devote) Author(header *types.Header) (common.Address, error)
- func (d *Devote) Authorize(signer string, signFn SignerFn)
- func (d *Devote) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (d *Devote) CheckWitness(lastBlock *types.Block, now int64) error
- func (d *Devote) Close() error
- func (d *Devote) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (d *Devote) GovernanceContract(fn GetGovernanceContractAddress)
- func (d *Devote) Masternodes(masternodeListFn MasternodeListFn)
- func (d *Devote) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (d *Devote) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (d *Devote) SealHash(header *types.Header) common.Hash
- func (d *Devote) SetDevoteDB(db ethdb.Database)
- func (d *Devote) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error
- func (d *Devote) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)
- func (d *Devote) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (d *Devote) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- type GetGovernanceContractAddress
- type MasternodeListFn
- type SignerFn
- type Snapshot
Constants ¶
This section is empty.
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") ErrInvalidBlockWitness = errors.New("invalid block witness") ErrMinerFutureBlock = errors.New("miner the future block") ErrWaitForPrevBlock = errors.New("wait for last block arrived") ErrNilBlockHeader = errors.New("nil block header returned") ErrMismatchSignerAndWitness = errors.New("mismatch block signer and witness") ErrInvalidMinerBlockTime = errors.New("invalid time to miner the block") )
Functions ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a user facing RPC API to allow controlling the delegate and voting mechanisms of the delegated-proof-of-stake
func (*API) Discard ¶
Discard drops a currently running proposal, stopping the signer from casting further votes (either for or against).
func (*API) GetConfirmedBlockNumber ¶
GetConfirmedBlockNumber retrieves the latest irreversible block
func (*API) GetSigners ¶
func (api *API) GetSigners(number *rpc.BlockNumber) ([]string, error)
GetSigners retrieves the list of the Witnesses at specified block
func (*API) GetSignersAtHash ¶
GetSignersAtHash retrieves the list of authorized signers at the specified block.
func (*API) GetSignersByEpoch ¶
GetSignersByEpoch retrieves the list of the Witnesses by round
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error)
GetSnapshot retrieves the state snapshot at a given block.
func (*API) GetSnapshotAtHash ¶
GetSnapshotAtHash retrieves the state snapshot at a given block.
type Devote ¶
type Devote struct {
// contains filtered or unexported fields
}
func (*Devote) APIs ¶
func (d *Devote) APIs(chain consensus.ChainReader) []rpc.API
APIs implements consensus.Engine, returning the user facing RPC APIs.
func (*Devote) Author ¶
Author implements consensus.Engine, returning the header's coinbase as the proof-of-stake verified author of the block.
func (*Devote) CalcDifficulty ¶
func (*Devote) CheckWitness ¶
func (*Devote) Close ¶
Close implements consensus.Engine. It's a noop for Devote as there is are no background threads.
func (*Devote) Finalize ¶
func (d *Devote) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
Finalize implements consensus.Engine, accumulating the block and uncle rewards, setting the final state and assembling the block.
func (*Devote) GovernanceContract ¶
func (d *Devote) GovernanceContract(fn GetGovernanceContractAddress)
func (*Devote) Masternodes ¶
func (d *Devote) Masternodes(masternodeListFn MasternodeListFn)
func (*Devote) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*Devote) Seal ¶
func (d *Devote) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
Seal generates a new block for the given input block with the local miner's seal place on top.
func (*Devote) SetDevoteDB ¶
func (*Devote) VerifyHeader ¶
verifyHeader checks whether a header conforms to the consensus rules of the stock Hkd devote engine.
func (*Devote) VerifyHeaders ¶
func (*Devote) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*Devote) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.
type Snapshot ¶
type Snapshot struct { Hash common.Hash //Block hash where the snapshot was created Number uint64 //Cycle number where the snapshot was created Cycle uint64 //Cycle number where the snapshot was created Signers map[string]struct{} `json:"signers"` // Set of authorized signers at this moment Recents map[uint64]string // set of recent masternodes for spam protections TimeStamp uint64 // contains filtered or unexported fields }