consensus

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	HitSize       = 8
	MinBaseTarget = 9
)

Variables

View Source
var (
	NXTPosCalculator    = PosCalculator(&nxtPosCalculator{})
	FairPosCalculatorV1 = NewFairPosCalculator(delayDeltaV1, tMinV1)
)
View Source
var (
	NXTGenerationSignatureProvider = GenerationSignatureProvider(&nxtGenerationSignatureProvider{})
	VRFGenerationSignatureProvider = GenerationSignatureProvider(&vrfGenerationSignatureProvider{})
)

Functions

This section is empty.

Types

type GenerationSignatureProvider added in v0.5.0

type GenerationSignatureProvider interface {
	// GenerationSignature calculates generation signature from given message using secret or public key of block's generator.
	GenerationSignature(key [crypto.KeySize]byte, msg []byte) ([]byte, error)

	// HitSource calculates hit source bytes for given message and key.
	HitSource(key [crypto.KeySize]byte, msg []byte) ([]byte, error)

	// VerifyGenerationSignature checks that generation signature is valid for given message and generator's public key.
	// It returns verification result and error if any.
	VerifyGenerationSignature(pk crypto.PublicKey, msg, sig []byte) (bool, []byte, error)
}

type Hit

type Hit = big.Int

func GenHit

func GenHit(source []byte) (*Hit, error)

type PosCalculator added in v0.5.0

type PosCalculator interface {
	HeightForHit(height uint64) uint64
	CalculateBaseTarget(
		targetBlockDelaySeconds uint64,
		prevHeight uint64,
		prevTarget uint64,
		parentTimestamp uint64,
		greatGrandParentTimestamp uint64,
		currentTimestamp uint64,
	) (uint64, error)
	CalculateDelay(hit *big.Int, parentTarget, balance uint64) (uint64, error)
}

func NewFairPosCalculator added in v0.10.0

func NewFairPosCalculator(delayDelta uint64, tMin float64) PosCalculator

NewFairPosCalculator creates a custom FairPosCalculator, if this parameter is not specified in the config, then FairPosCalculatorV2 is used by default

type Validator added in v0.9.0

type Validator struct {
	// contains filtered or unexported fields
}

func NewValidator added in v0.9.0

func NewValidator(state stateInfoProvider, settings *settings.BlockchainSettings, tm types.Time) *Validator

func (*Validator) GenerateHitSource added in v0.9.0

func (cv *Validator) GenerateHitSource(height uint64, header proto.BlockHeader) ([]byte, error)

func (*Validator) ShouldIncludeNewBlockFieldsOfLightNodeFeature added in v0.11.0

func (cv *Validator) ShouldIncludeNewBlockFieldsOfLightNodeFeature(blockHeight proto.Height) (bool, error)

ShouldIncludeNewBlockFieldsOfLightNodeFeature checks if new block fields can be included after LightNode feature activation in the context of current state.

func (*Validator) ValidateHeaderBeforeBlockApplying added in v0.10.0

func (cv *Validator) ValidateHeaderBeforeBlockApplying(
	newestHeader *proto.BlockHeader,
	blockchainHeight proto.Height,
) error

func (*Validator) ValidateHeadersBatch added in v0.10.0

func (cv *Validator) ValidateHeadersBatch(headers []proto.BlockHeader, startHeight proto.Height) error

Jump to

Keyboard shortcuts

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