engine_v1

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetM1M2FromCheckpointHeader added in v1.4.3

func GetM1M2FromCheckpointHeader(checkpointHeader *types.Header, currentHeader *types.Header, config *params.ChainConfig) (map[common.Address]common.Address, error)

Get m2 list from checkpoint block.

func GetMasternodesFromCheckpointHeader added in v1.4.3

func GetMasternodesFromCheckpointHeader(checkpointHeader *types.Header) []common.Address

Get masternodes address from checkpoint Header.

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 NewFaker

func NewFaker(db ethdb.Database, config *params.XDPoSConfig) *XDPoS_v1

func (*XDPoS_v1) Author

func (x *XDPoS_v1) 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_v1) Authorize

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

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

func (*XDPoS_v1) GetDb

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

func (*XDPoS_v1) GetMasternodes

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

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

func (x *XDPoS_v1) GetPeriod() uint64

func (*XDPoS_v1) GetSnapshot

func (x *XDPoS_v1) GetSnapshot(chain consensus.ChainReader, header *types.Header) (*SnapshotV1, error)

func (*XDPoS_v1) GetValidator

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

func (*XDPoS_v1) IsAuthorisedAddress

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

func (*XDPoS_v1) Prepare

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

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

func (*XDPoS_v1) RecoverValidator

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

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

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

func (x *XDPoS_v1) 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_v1) YourTurn

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

Jump to

Keyboard shortcuts

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