Documentation ¶
Overview ¶
Package XDPoS is the adaptor for different consensus engine.
Index ¶
- Constants
- type API
- func (api *API) GetLatestPoolStatus() MessageStatus
- func (api *API) GetMasternodesByNumber(number *rpc.BlockNumber) MasternodesStatus
- func (api *API) GetMissedRoundsInEpochByBlockNum(number *rpc.BlockNumber) (*utils.PublicApiMissedRoundsMetadata, error)
- func (api *API) GetSigners(number *rpc.BlockNumber) ([]common.Address, error)
- func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error)
- func (api *API) GetSnapshot(number *rpc.BlockNumber) (*utils.PublicApiSnapshot, error)
- func (api *API) GetSnapshotAtHash(hash common.Hash) (*utils.PublicApiSnapshot, error)
- func (api *API) GetV2BlockByHash(blockHash common.Hash) *V2BlockInfo
- func (api *API) GetV2BlockByHeader(header *types.Header, uncle bool) *V2BlockInfo
- func (api *API) GetV2BlockByNumber(number *rpc.BlockNumber) *V2BlockInfo
- func (api *API) NetworkInformation() NetworkInformation
- type MasternodesStatus
- type MessageStatus
- type NetworkInformation
- type SignerTypes
- type V2BlockInfo
- type XDPoS
- func (x *XDPoS) APIs(chain consensus.ChainReader) []rpc.API
- func (x *XDPoS) Author(header *types.Header) (common.Address, error)
- func (x *XDPoS) Authorize(signer common.Address, signFn clique.SignerFn)
- func (x *XDPoS) CacheNoneTIPSigningTxs(header *types.Header, txs []*types.Transaction, receipts []*types.Receipt) []*types.Transaction
- func (x *XDPoS) CacheSigningTxs(hash common.Hash, txs []*types.Transaction) []*types.Transaction
- func (x *XDPoS) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (x *XDPoS) CalculateMissingRounds(chain consensus.ChainReader, header *types.Header) (*utils.PublicApiMissedRoundsMetadata, error)
- func (x *XDPoS) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (x *XDPoS) FindParentBlockToAssign(chain consensus.ChainReader, currentBlock *types.Block) *types.Block
- func (x *XDPoS) GetAuthorisedSignersFromSnapshot(chain consensus.ChainReader, header *types.Header) ([]common.Address, error)
- func (x *XDPoS) GetCachedSigningTxs(hash common.Hash) (interface{}, bool)
- func (x *XDPoS) GetCurrentEpochSwitchBlock(chain consensus.ChainReader, blockNumber *big.Int) (uint64, uint64, error)
- func (x *XDPoS) GetDb() ethdb.Database
- func (x *XDPoS) GetMasternodes(chain consensus.ChainReader, header *types.Header) []common.Address
- func (x *XDPoS) GetMasternodesByNumber(chain consensus.ChainReader, blockNumber uint64) []common.Address
- func (x *XDPoS) GetMasternodesFromCheckpointHeader(checkpointHeader *types.Header) []common.Address
- func (x *XDPoS) GetPeriod() uint64
- func (x *XDPoS) GetSnapshot(chain consensus.ChainReader, header *types.Header) (*utils.PublicApiSnapshot, error)
- func (x *XDPoS) GetValidator(creator common.Address, chain consensus.ChainReader, header *types.Header) (common.Address, error)
- func (x *XDPoS) HandleProposedBlock(chain consensus.ChainReader, header *types.Header) error
- func (x *XDPoS) Initial(chain consensus.ChainReader, header *types.Header) error
- func (x *XDPoS) IsAuthorisedAddress(chain consensus.ChainReader, header *types.Header, address common.Address) bool
- func (x *XDPoS) IsEpochSwitch(header *types.Header) (bool, uint64, error)
- func (x *XDPoS) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (x *XDPoS) RecoverSigner(header *types.Header) (common.Address, error)
- func (x *XDPoS) RecoverValidator(header *types.Header) (common.Address, error)
- func (x *XDPoS) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (x *XDPoS) SigHash(header *types.Header) (hash common.Hash)
- func (x *XDPoS) SubscribeForensicsEvent(ch chan<- types.ForensicsEvent) event.Subscription
- func (x *XDPoS) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error
- func (x *XDPoS) UpdateParams(header *types.Header)
- func (x *XDPoS) VerifyHeader(chain consensus.ChainReader, header *types.Header, fullVerify bool) error
- func (x *XDPoS) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, fullVerifies []bool) (chan<- struct{}, <-chan error)
- func (x *XDPoS) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (x *XDPoS) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- func (x *XDPoS) YourTurn(chain consensus.ChainReader, parent *types.Header, signer common.Address) (bool, error)
Constants ¶
const ( ExtraFieldCheck = true SkipExtraFieldCheck = false )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { XDPoS *XDPoS // 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) GetLatestPoolStatus ¶
func (api *API) GetLatestPoolStatus() MessageStatus
Get current vote pool and timeout pool content and missing messages
func (*API) GetMasternodesByNumber ¶
func (api *API) GetMasternodesByNumber(number *rpc.BlockNumber) MasternodesStatus
func (*API) GetMissedRoundsInEpochByBlockNum ¶ added in v1.6.0
func (api *API) GetMissedRoundsInEpochByBlockNum(number *rpc.BlockNumber) (*utils.PublicApiMissedRoundsMetadata, error)
An API exclusively for V2 consensus, designed to assist in troubleshooting miners by identifying who mined during their allocated term.
func (*API) GetSigners ¶
GetSigners retrieves the list of authorized signers at the specified block.
func (*API) GetSignersAtHash ¶
GetSignersAtHash retrieves the state snapshot at a given block.
func (*API) GetSnapshot ¶
func (api *API) GetSnapshot(number *rpc.BlockNumber) (*utils.PublicApiSnapshot, error)
GetSnapshot retrieves the state snapshot at a given block.
func (*API) GetSnapshotAtHash ¶
GetSnapshotAtHash retrieves the state snapshot at a given block.
func (*API) GetV2BlockByHash ¶
func (api *API) GetV2BlockByHash(blockHash common.Hash) *V2BlockInfo
Confirm V2 Block Committed Status
func (*API) GetV2BlockByHeader ¶
func (api *API) GetV2BlockByHeader(header *types.Header, uncle bool) *V2BlockInfo
func (*API) GetV2BlockByNumber ¶
func (api *API) GetV2BlockByNumber(number *rpc.BlockNumber) *V2BlockInfo
func (*API) NetworkInformation ¶
func (api *API) NetworkInformation() NetworkInformation
type MasternodesStatus ¶
type MessageStatus ¶
type MessageStatus map[string]map[string]SignerTypes
type NetworkInformation ¶
type SignerTypes ¶
type V2BlockInfo ¶
type XDPoS ¶
type XDPoS struct { // Share Channel MinePeriodCh chan int // Miner wait Period Channel // Trading and lending service GetXDCXService func() utils.TradingService GetLendingService func() utils.LendingService // The exact consensus engine with different versions EngineV1 *engine_v1.XDPoS_v1 EngineV2 *engine_v2.XDPoS_v2 // contains filtered or unexported fields }
XDPoS is the delegated-proof-of-stake consensus engine proposed to support the Ethereum testnet following the Ropsten attacks.
func New ¶
func New(chainConfig *params.ChainConfig, db ethdb.Database) *XDPoS
New creates a XDPoS delegated-proof-of-stake consensus engine with the initial signers set to the ones provided by the user.
func NewFaker ¶
func NewFaker(db ethdb.Database, chainConfig *params.ChainConfig) *XDPoS
NewFullFaker creates an ethash consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.
func (*XDPoS) APIs ¶
func (x *XDPoS) APIs(chain consensus.ChainReader) []rpc.API
Eth Consensus engine interface implementation
APIs implements consensus.Engine, returning the user facing RPC API to allow controlling the signer voting.
func (*XDPoS) Author ¶
Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.
func (*XDPoS) Authorize ¶
Authorize injects a private key into the consensus engine to mint new blocks with.
func (*XDPoS) CacheNoneTIPSigningTxs ¶
func (x *XDPoS) CacheNoneTIPSigningTxs(header *types.Header, txs []*types.Transaction, receipts []*types.Receipt) []*types.Transaction
Cache signing transaction data into BlockSingers cache object
func (*XDPoS) CacheSigningTxs ¶
func (x *XDPoS) CacheSigningTxs(hash common.Hash, txs []*types.Transaction) []*types.Transaction
Cache
func (*XDPoS) CalcDifficulty ¶
func (x *XDPoS) 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 (*XDPoS) CalculateMissingRounds ¶ added in v1.6.0
func (x *XDPoS) CalculateMissingRounds(chain consensus.ChainReader, header *types.Header) (*utils.PublicApiMissedRoundsMetadata, error)
func (*XDPoS) Finalize ¶
func (x *XDPoS) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, parentState *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)
Finalize implements consensus.Engine, ensuring no uncles are set, nor block rewards given, and returns the final block.
func (*XDPoS) FindParentBlockToAssign ¶
func (*XDPoS) GetAuthorisedSignersFromSnapshot ¶
func (*XDPoS) GetCachedSigningTxs ¶
func (*XDPoS) GetCurrentEpochSwitchBlock ¶
func (*XDPoS) GetMasternodes ¶
func (*XDPoS) GetMasternodesByNumber ¶
func (*XDPoS) GetMasternodesFromCheckpointHeader ¶
Get master nodes over extra data of previous checkpoint block.
func (*XDPoS) GetSnapshot ¶
func (x *XDPoS) GetSnapshot(chain consensus.ChainReader, header *types.Header) (*utils.PublicApiSnapshot, error)
func (*XDPoS) GetValidator ¶
func (*XDPoS) HandleProposedBlock ¶
func (*XDPoS) IsAuthorisedAddress ¶
func (*XDPoS) IsEpochSwitch ¶
Check is epoch switch (checkpoint) block
func (*XDPoS) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*XDPoS) RecoverSigner ¶
func (*XDPoS) RecoverValidator ¶
func (*XDPoS) Seal ¶
func (x *XDPoS) 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 (*XDPoS) SubscribeForensicsEvent ¶
func (x *XDPoS) SubscribeForensicsEvent(ch chan<- types.ForensicsEvent) event.Subscription
Subscribe to consensus engines forensics events. Currently only exist for engine v2
func (*XDPoS) UpdateMasternodes ¶
func (x *XDPoS) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error
func (*XDPoS) UpdateParams ¶
Reset parameters after checkpoint due to config may change
func (*XDPoS) VerifyHeader ¶
func (x *XDPoS) VerifyHeader(chain consensus.ChainReader, header *types.Header, fullVerify bool) error
VerifyHeader checks whether a header conforms to the consensus rules.
func (*XDPoS) VerifyHeaders ¶
func (x *XDPoS) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, fullVerifies []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 (*XDPoS) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*XDPoS) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.