finalizationconsensus

package
v3.1.7-near-hf Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLatestFinalizedBlock

func GetLatestFinalizedBlock(latestBlock, blockDistanceForFinalizedData int64) int64

func InterpolateBlocks

func InterpolateBlocks(timeNow, latestBlockTime time.Time, averageBlockTime time.Duration) int64

Types

type BlockToHashesToAgreeingProviders

type BlockToHashesToAgreeingProviders map[int64]map[string]map[string]providerDataContainer // first key is block num, second key is block hash, third key is provider address

type ChainBlockStatsGetter

type ChainBlockStatsGetter interface {
	ChainBlockStats() (allowedBlockLagForQosSync int64, averageBlockTime time.Duration, blockDistanceForFinalizedData, blocksInFinalizationProof uint32)
}

type FinalizationConsensus

type FinalizationConsensus struct {
	SpecId string
	// contains filtered or unexported fields
}

func NewFinalizationConsensus

func NewFinalizationConsensus(specId string) *FinalizationConsensus

func (*FinalizationConsensus) GetExpectedBlockHeight

func (fc *FinalizationConsensus) GetExpectedBlockHeight(chainParser ChainBlockStatsGetter) (expectedBlockHeight int64, numOfProviders int)

Returns the expected latest block to be at based on the current finalization data, and the number of providers we have information for. It does the calculation on finalized entries then extrapolates the ending based on blockDistance

func (*FinalizationConsensus) NewEpoch

func (fc *FinalizationConsensus) NewEpoch(epoch uint64)

func (*FinalizationConsensus) UpdateFinalizedHashes

func (fc *FinalizationConsensus) UpdateFinalizedHashes(blockDistanceForFinalizedData int64, consumerAddress sdk.AccAddress, providerAddress string, finalizedBlocks map[int64]string, relaySession *pairingtypes.RelaySession, reply *pairingtypes.RelayReply) (finalizationConflict *conflicttypes.FinalizationConflict, err error)

Compare finalized block hashes with previous providers Looks for discrepancy with current epoch providers if no conflicts, insert into consensus and break create new consensus group if no consensus matched check for discrepancy with old epoch checks if there is a consensus mismatch between hashes provided by different providers

type FinalizationConsensusInf

type FinalizationConsensusInf interface {
	UpdateFinalizedHashes(
		blockDistanceForFinalizedData int64,
		consumerAddress sdk.AccAddress,
		providerAddress string,
		finalizedBlocks map[int64]string,
		relaySession *pairingtypes.RelaySession,
		reply *pairingtypes.RelayReply,
	) (finalizationConflict *conflicttypes.FinalizationConflict, err error)
	GetExpectedBlockHeight(chainParser ChainBlockStatsGetter) (expectedBlockHeight int64, numOfProviders int)
	NewEpoch(epoch uint64)
}

Jump to

Keyboard shortcuts

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