Documentation ¶
Overview ¶
Package XDPoS is the adaptor for different consensus engine.
Index ¶
- func SigHash(header *types.Header) (hash common.Hash)
- type API
- 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) NetworkInformation() NetworkInformation
- type NetworkInformation
- 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) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- 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) GetDb() ethdb.Database
- func (x *XDPoS) GetMasternodes(chain consensus.ChainReader, header *types.Header) []common.Address
- func (x *XDPoS) GetMasternodesFromCheckpointHeader(preCheckpointHeader *types.Header, n, e uint64) []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) IsAuthorisedAddress(header *types.Header, chain consensus.ChainReader, address common.Address) bool
- 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) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error
- 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) (int, int, int, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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) 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) NetworkInformation ¶
func (api *API) NetworkInformation() NetworkInformation
type NetworkInformation ¶
type XDPoS ¶
type XDPoS struct { // 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(config *params.XDPoSConfig, 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) 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) GetAuthorisedSignersFromSnapshot ¶
func (*XDPoS) GetCachedSigningTxs ¶
func (*XDPoS) GetMasternodes ¶
func (*XDPoS) GetMasternodesFromCheckpointHeader ¶
func (x *XDPoS) GetMasternodesFromCheckpointHeader(preCheckpointHeader *types.Header, n, e uint64) []common.Address
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) IsAuthorisedAddress ¶
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) UpdateMasternodes ¶
func (x *XDPoS) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error
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.