devote

package
v0.0.0-...-774b582 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package devote implements the proof-of-authority consensus engine.

Package devote implements the proof-of-stake consensus engine.

Index

Constants

This section is empty.

Variables

View Source
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

func AccumulateRewards

func AccumulateRewards(govAddress common.Address, state *state.StateDB, header *types.Header, uncles []*types.Header)

AccumulateRewards credits the coinbase of the given block with the mining reward. The devote consensus allowed uncle block .

func NextSlot

func NextSlot(now uint64) uint64

func PrevSlot

func PrevSlot(now uint64) uint64

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

func (api *API) Discard(signer string)

Discard drops a currently running proposal, stopping the signer from casting further votes (either for or against).

func (*API) GetConfirmedBlockNumber

func (api *API) GetConfirmedBlockNumber() (*big.Int, error)

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

func (api *API) GetSignersAtHash(hash common.Hash) ([]string, error)

GetSignersAtHash retrieves the list of authorized signers at the specified block.

func (*API) GetSignersByEpoch

func (api *API) GetSignersByEpoch(epoch uint64) ([]string, error)

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

func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error)

GetSnapshotAtHash retrieves the state snapshot at a given block.

func (*API) Proposals

func (api *API) Proposals() map[string]bool

Proposals returns the current proposals the node tries to uphold and vote on.

func (*API) Propose

func (api *API) Propose(signer string, auth bool)

Propose injects a new authorization proposal that the signer will attempt to push through.

type Devote

type Devote struct {
	// contains filtered or unexported fields
}

func NewDevote

func NewDevote(config *params.DevoteConfig, db ethdb.Database) *Devote

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

func (d *Devote) Author(header *types.Header) (common.Address, error)

Author implements consensus.Engine, returning the header's coinbase as the proof-of-stake verified author of the block.

func (*Devote) Authorize

func (d *Devote) Authorize(signer string, signFn SignerFn)

func (*Devote) CalcDifficulty

func (d *Devote) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int

func (*Devote) CheckWitness

func (d *Devote) CheckWitness(lastBlock *types.Block, now int64) error

func (*Devote) Close

func (d *Devote) Close() error

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

func (d *Devote) Prepare(chain consensus.ChainReader, header *types.Header) error

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

func (d *Devote) SealHash(header *types.Header) common.Hash

SealHash returns the hash of a block prior to it being sealed.

func (*Devote) SetDevoteDB

func (d *Devote) SetDevoteDB(db ethdb.Database)

func (*Devote) VerifyHeader

func (d *Devote) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error

verifyHeader checks whether a header conforms to the consensus rules of the stock Hkd devote engine.

func (*Devote) VerifyHeaders

func (d *Devote) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)

func (*Devote) VerifySeal

func (d *Devote) VerifySeal(chain consensus.ChainReader, header *types.Header) error

VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.

func (*Devote) VerifyUncles

func (d *Devote) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.

type GetGovernanceContractAddress

type GetGovernanceContractAddress func(number *big.Int) (common.Address, error)

type MasternodeListFn

type MasternodeListFn func(number *big.Int) ([]string, error)

type SignerFn

type SignerFn func(string, []byte) ([]byte, error)

SignerFn string:master node nodeid,[8]byte []byte,signature

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
}

Jump to

Keyboard shortcuts

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