XDPoS

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Overview

Package XDPoS is the adaptor for different consensus engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SigHash added in v1.0.0

func SigHash(header *types.Header) (hash common.Hash)

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

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.

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

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

GetSnapshotAtHash retrieves the state snapshot at a given block.

func (*API) NetworkInformation

func (api *API) NetworkInformation() NetworkInformation

type NetworkInformation

type NetworkInformation struct {
	NetworkId                  *big.Int
	XDCValidatorAddress        common.Address
	RelayerRegistrationAddress common.Address
	XDCXListingAddress         common.Address
	XDCZAddress                common.Address
	LendingAddress             common.Address
}

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

func (x *XDPoS) Author(header *types.Header) (common.Address, error)

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

func (*XDPoS) Authorize

func (x *XDPoS) Authorize(signer common.Address, signFn clique.SignerFn)

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 (x *XDPoS) GetAuthorisedSignersFromSnapshot(chain consensus.ChainReader, header *types.Header) ([]common.Address, error)

func (*XDPoS) GetCachedSigningTxs

func (x *XDPoS) GetCachedSigningTxs(hash common.Hash) (interface{}, bool)

func (*XDPoS) GetDb

func (x *XDPoS) GetDb() ethdb.Database

Same DB across all consensus engines

func (*XDPoS) GetMasternodes

func (x *XDPoS) GetMasternodes(chain consensus.ChainReader, header *types.Header) []common.Address

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

func (x *XDPoS) GetPeriod() uint64

func (*XDPoS) GetSnapshot

func (x *XDPoS) GetSnapshot(chain consensus.ChainReader, header *types.Header) (*utils.PublicApiSnapshot, error)

func (*XDPoS) GetValidator

func (x *XDPoS) GetValidator(creator common.Address, chain consensus.ChainReader, header *types.Header) (common.Address, error)

func (*XDPoS) IsAuthorisedAddress

func (x *XDPoS) IsAuthorisedAddress(header *types.Header, chain consensus.ChainReader, address common.Address) bool

func (*XDPoS) Prepare

func (x *XDPoS) 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 (*XDPoS) RecoverSigner

func (x *XDPoS) RecoverSigner(header *types.Header) (common.Address, error)

func (*XDPoS) RecoverValidator

func (x *XDPoS) RecoverValidator(header *types.Header) (common.Address, error)

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

func (x *XDPoS) 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 (*XDPoS) VerifyUncles

func (x *XDPoS) 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.

func (*XDPoS) YourTurn

func (x *XDPoS) YourTurn(chain consensus.ChainReader, parent *types.Header, signer common.Address) (int, int, int, bool, error)

Directories

Path Synopsis
engines

Jump to

Keyboard shortcuts

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