dpos

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2019 License: GPL-3.0 Imports: 25 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VortexBlockReward     *big.Int = big.NewInt(24e+17) // 2.4VNT
	VortexCandidatesBonus *big.Int = big.NewInt(16e+17) // 1.6VNT

)

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 *API) GetCommitMsgs() []*types.CommitMsg

func (*API) GetCurrentHeight

func (api *API) GetCurrentHeight() *big.Int

func (*API) GetCurrentRound

func (api *API) GetCurrentRound() uint32

func (*API) GetCurrentStep

func (api *API) GetCurrentStep() uint32

func (*API) GetPrePrepareMsg

func (api *API) GetPrePrepareMsg() *types.PreprepareMsg

func (*API) GetPrepareMsgs

func (api *API) GetPrepareMsgs() []*types.PrepareMsg

func (*API) GetSigners

func (api *API) GetSigners(number *rpc.BlockNumber) ([]common.Address, error)

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

func (*API) GetSignersAtHash

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

GetSignersAtHash retrieves the state snapshot at a given 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

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

Author implements consensus.Engine, returning the VNT address recovered from the signature in the header's extra-data section.

func (*Dpos) Authorize

func (d *Dpos) Authorize(signer common.Address, signFn SignerFn)

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 (d *Dpos) CleanOldMsg(h *big.Int)

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

func (d *Dpos) GetWitnessesFromStateDB(stateDB *state.StateDB) ([]common.Address, []string)

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

func (d *Dpos) InitBft(sendBftMsg func(types.ConsensusMsg), SendPeerUpdate func(urls []string), verifyBlock func(*types.Block) (types.Receipts, []*types.Log, uint64, error), writeBlock func(*types.Block) error)

func (*Dpos) Prepare

func (d *Dpos) 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 (*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) VerifyCommitMsg

func (d *Dpos) VerifyCommitMsg(block *types.Block) error

func (*Dpos) VerifyHeader

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

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

func (d *Dpos) 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 (*Dpos) VerifyWitnesses

func (d *Dpos) VerifyWitnesses(header *types.Header, db *state.StateDB, parent *types.Header) error

VerifyWitnesses Verify witness list and update time(header.Extra) for DPoS

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

func NewManager

func NewManager(period uint64, witnesses []common.Address) *Manager

NewManager creating a dpos witness manager

type SignerFn

type SignerFn func(accounts.Account, []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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