consensus

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	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) RangeForGeneratingBalanceByHeight added in v0.9.0

func (cv *Validator) RangeForGeneratingBalanceByHeight(height uint64) (uint64, uint64)

func (*Validator) ValidateHeaderBeforeBlockApplying added in v0.10.0

func (cv *Validator) ValidateHeaderBeforeBlockApplying(newestHeader *proto.BlockHeader, height 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