CratD2C

package
v0.0.0-...-18fe305 Latest Latest
Warning

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

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

Documentation

Overview

Package CratD2C is the adaptor for different consensus engine.

Index

Constants

View Source
const (
	ExtraFieldCheck     = true
	SkipExtraFieldCheck = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	XDPoS *CratD2C
	// 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) 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) 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 CratD2C

type CratD2C 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
	EngineV2 *engine_v2.CratD2C_v2
	// contains filtered or unexported fields
}

CratD2C is the delegated-proof-of-stake consensus engine.

func New

func New(chainConfig *params.ChainConfig, db ethdb.Database) *CratD2C

New creates a CratD2C 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) *CratD2C

NewFullFaker creates an ethash consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.

func (*CratD2C) APIs

func (x *CratD2C) 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 (*CratD2C) Author

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

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

Authorize injects a private key into the consensus engine to mint new blocks with.

func (*CratD2C) CacheNoneTIPSigningTxs

func (x *CratD2C) CacheNoneTIPSigningTxs(header *types.Header, txs []*types.Transaction, receipts []*types.Receipt) []*types.Transaction

Cache signing transaction data into BlockSingers cache object

func (*CratD2C) CacheSigningTxs

func (x *CratD2C) CacheSigningTxs(hash common.Hash, txs []*types.Transaction) []*types.Transaction

Cache

func (*CratD2C) CalcDifficulty

func (x *CratD2C) 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 (*CratD2C) Finalize

func (x *CratD2C) 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 (*CratD2C) FindParentBlockToAssign

func (x *CratD2C) FindParentBlockToAssign(chain consensus.ChainReader, currentBlock *types.Block) *types.Block

func (*CratD2C) GetAuthorisedSignersFromSnapshot

func (x *CratD2C) GetAuthorisedSignersFromSnapshot(chain consensus.ChainReader, header *types.Header) ([]common.Address, error)

func (*CratD2C) GetCachedSigningTxs

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

func (*CratD2C) GetCurrentEpochSwitchBlock

func (x *CratD2C) GetCurrentEpochSwitchBlock(chain consensus.ChainReader, blockNumber *big.Int) (uint64, uint64, error)

func (*CratD2C) GetDb

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

Same DB across all consensus engines

func (*CratD2C) GetMasternodes

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

func (*CratD2C) GetMasternodesByNumber

func (x *CratD2C) GetMasternodesByNumber(chain consensus.ChainReader, blockNumber uint64) []common.Address

func (*CratD2C) GetMasternodesFromCheckpointHeader

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

Get master nodes over extra data of previous checkpoint block.

func (*CratD2C) GetPeriod

func (x *CratD2C) GetPeriod() uint64

func (*CratD2C) GetSnapshot

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

func (*CratD2C) GetValidator

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

func (*CratD2C) HandleProposedBlock

func (x *CratD2C) HandleProposedBlock(chain consensus.ChainReader, header *types.Header) error

func (*CratD2C) Initial

func (x *CratD2C) Initial(chain consensus.ChainReader, header *types.Header) error

func (*CratD2C) IsAuthorisedAddress

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

func (*CratD2C) IsEpochSwitch

func (x *CratD2C) IsEpochSwitch(header *types.Header) (bool, uint64, error)

Check is epoch switch (checkpoint) block

func (*CratD2C) Prepare

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

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

func (*CratD2C) RecoverValidator

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

func (*CratD2C) Seal

func (x *CratD2C) 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 (*CratD2C) SigHash

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

func (*CratD2C) SubscribeForensicsEvent

func (x *CratD2C) SubscribeForensicsEvent(ch chan<- types.ForensicsEvent) event.Subscription

Subscribe to consensus engines forensics events. Currently only exist for engine v2

func (*CratD2C) UpdateMasternodes

func (x *CratD2C) UpdateMasternodes(chain consensus.ChainReader, header *types.Header, ms []utils.Masternode) error

func (*CratD2C) UpdateParams

func (x *CratD2C) UpdateParams(header *types.Header)

Reset parameters after checkpoint due to config may change

func (*CratD2C) VerifyHeader

func (x *CratD2C) VerifyHeader(chain consensus.ChainReader, header *types.Header, fullVerify bool) error

VerifyHeader checks whether a header conforms to the consensus rules.

func (*CratD2C) VerifyHeaders

func (x *CratD2C) 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 (*CratD2C) VerifySeal

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

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

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

type MasternodesStatus

type MasternodesStatus struct {
	Number          uint64
	Round           types.Round
	MasternodesLen  int
	Masternodes     []common.Address
	PenaltyLen      int
	Penalty         []common.Address
	StandbynodesLen int
	Standbynodes    []common.Address
	Error           error
}

type MessageStatus

type MessageStatus map[string]map[string]SignerTypes

type NetworkInformation

type NetworkInformation struct {
	NetworkId                  *big.Int
	XDCValidatorAddress        common.Address
	RelayerRegistrationAddress common.Address
	Denom                      string
	NetworkName                string
}

type SignerTypes

type SignerTypes struct {
	CurrentNumber  int
	CurrentSigners []common.Address
	MissingSigners []common.Address
}

type V2BlockInfo

type V2BlockInfo struct {
	Hash       common.Hash
	Round      types.Round
	Number     *big.Int
	ParentHash common.Hash
	Committed  bool
	Miner      common.Hash
	Timestamp  *big.Int
	HexRLP     string
	Error      string
}

Directories

Path Synopsis
engines

Jump to

Keyboard shortcuts

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