Documentation ¶
Index ¶
- func GetM1M2FromCheckpointHeader(checkpointHeader *types.Header, currentHeader *types.Header, ...) (map[common.Address]common.Address, error)
- func GetMasternodesFromCheckpointHeader(checkpointHeader *types.Header) []common.Address
- type SnapshotV1
- type XDPoS_v1
- func (x *XDPoS_v1) Author(header *types.Header) (common.Address, error)
- func (x *XDPoS_v1) Authorize(signer common.Address, signFn clique.SignerFn)
- func (x *XDPoS_v1) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int
- func (x *XDPoS_v1) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, ...) (*types.Block, error)
- func (x *XDPoS_v1) GetAuthorisedSignersFromSnapshot(chain consensus.ChainReader, header *types.Header) ([]common.Address, error)
- func (x *XDPoS_v1) GetDb() ethdb.Database
- func (x *XDPoS_v1) GetMasternodes(chain consensus.ChainReader, header *types.Header) []common.Address
- func (x *XDPoS_v1) GetMasternodesFromCheckpointHeader(preCheckpointHeader *types.Header, n, e uint64) []common.Address
- func (x *XDPoS_v1) GetPeriod() uint64
- func (x *XDPoS_v1) GetSnapshot(chain consensus.ChainReader, header *types.Header) (*SnapshotV1, error)
- func (x *XDPoS_v1) GetValidator(creator common.Address, chain consensus.ChainReader, header *types.Header) (common.Address, error)
- func (x *XDPoS_v1) IsAuthorisedAddress(header *types.Header, chain consensus.ChainReader, address common.Address) bool
- func (x *XDPoS_v1) Prepare(chain consensus.ChainReader, header *types.Header) error
- func (x *XDPoS_v1) RecoverSigner(header *types.Header) (common.Address, error)
- func (x *XDPoS_v1) RecoverValidator(header *types.Header) (common.Address, error)
- func (x *XDPoS_v1) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
- func (x *XDPoS_v1) StoreSnapshot(snap *SnapshotV1) error
- func (x *XDPoS_v1) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error
- func (x *XDPoS_v1) VerifyHeader(chain consensus.ChainReader, header *types.Header, fullVerify bool) error
- func (x *XDPoS_v1) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, fullVerifies []bool) (chan<- struct{}, <-chan error)
- func (x *XDPoS_v1) VerifySeal(chain consensus.ChainReader, header *types.Header) error
- func (x *XDPoS_v1) VerifyUncles(chain consensus.ChainReader, block *types.Block) error
- func (x *XDPoS_v1) 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 SnapshotV1 ¶
type SnapshotV1 struct { Number uint64 `json:"number"` // Block number where the snapshot was created Hash common.Hash `json:"hash"` // Block hash where the snapshot was created Signers map[common.Address]struct{} `json:"signers"` // Set of authorized signers at this moment Recents map[uint64]common.Address `json:"recents"` // Set of recent signers for spam protections Votes []*clique.Vote `json:"votes"` // List of votes cast in chronological order Tally map[common.Address]clique.Tally `json:"tally"` // Current vote tally to avoid recalculating // contains filtered or unexported fields }
Snapshot is the state of the authorization voting at a given point in time.
func (*SnapshotV1) GetSigners ¶
func (s *SnapshotV1) GetSigners() []common.Address
signers retrieves the list of authorized signers in ascending order.
type XDPoS_v1 ¶
type XDPoS_v1 struct { HookReward func(chain consensus.ChainReader, state *state.StateDB, parentState *state.StateDB, header *types.Header) (error, map[string]interface{}) HookPenalty func(chain consensus.ChainReader, blockNumberEpoc uint64) ([]common.Address, error) HookPenaltyTIPSigning func(chain consensus.ChainReader, header *types.Header, candidate []common.Address) ([]common.Address, error) HookValidator func(header *types.Header, signers []common.Address) ([]byte, error) HookVerifyMNs func(header *types.Header, signers []common.Address) error HookGetSignersFromContract func(blockHash common.Hash) ([]common.Address, error) // 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_v1
New creates a XDPoS delegated-proof-of-stake consensus engine with the initial signers set to the ones provided by the user.
func (*XDPoS_v1) Author ¶
Author implements consensus.Engine, returning the Ethereum address recovered from the signature in the header's extra-data section.
func (*XDPoS_v1) Authorize ¶
Authorize injects a private key into the consensus engine to mint new blocks with.
func (*XDPoS_v1) CalcDifficulty ¶
func (x *XDPoS_v1) 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_v1) Finalize ¶
func (x *XDPoS_v1) 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_v1) GetAuthorisedSignersFromSnapshot ¶
func (*XDPoS_v1) GetMasternodes ¶
func (*XDPoS_v1) GetMasternodesFromCheckpointHeader ¶
func (x *XDPoS_v1) GetMasternodesFromCheckpointHeader(preCheckpointHeader *types.Header, n, e uint64) []common.Address
Get master nodes over extra data of previous checkpoint block.
func (*XDPoS_v1) GetSnapshot ¶
func (x *XDPoS_v1) GetSnapshot(chain consensus.ChainReader, header *types.Header) (*SnapshotV1, error)
func (*XDPoS_v1) GetValidator ¶
func (*XDPoS_v1) IsAuthorisedAddress ¶
func (*XDPoS_v1) Prepare ¶
Prepare implements consensus.Engine, preparing all the consensus fields of the header for running the transactions on top.
func (*XDPoS_v1) RecoverSigner ¶
func (*XDPoS_v1) RecoverValidator ¶
func (*XDPoS_v1) Seal ¶
func (x *XDPoS_v1) 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_v1) StoreSnapshot ¶
func (x *XDPoS_v1) StoreSnapshot(snap *SnapshotV1) error
func (*XDPoS_v1) UpdateMasternodes ¶
func (x *XDPoS_v1) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error
func (*XDPoS_v1) VerifyHeader ¶
func (x *XDPoS_v1) VerifyHeader(chain consensus.ChainReader, header *types.Header, fullVerify bool) error
VerifyHeader checks whether a header conforms to the consensus rules.
func (*XDPoS_v1) VerifyHeaders ¶
func (x *XDPoS_v1) 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_v1) VerifySeal ¶
VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.
func (*XDPoS_v1) VerifyUncles ¶
VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.