consensus

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FairPosCalculatorV1 added in v0.6.0

type FairPosCalculatorV1 struct {
}

func (*FairPosCalculatorV1) CalculateBaseTarget added in v0.6.0

func (calc *FairPosCalculatorV1) CalculateBaseTarget(
	targetBlockDelaySeconds uint64,
	confirmedHeight uint64,
	confirmedTarget uint64,
	confirmedTimestamp uint64,
	greatGrandParentTimestamp uint64,
	applyingBlockTimestamp uint64,
) (types.BaseTarget, error)

func (*FairPosCalculatorV1) CalculateDelay added in v0.6.0

func (calc *FairPosCalculatorV1) CalculateDelay(hit *Hit, confirmedTarget types.BaseTarget, balance uint64) (uint64, error)

func (*FairPosCalculatorV1) HeightForHit added in v0.6.0

func (calc *FairPosCalculatorV1) HeightForHit(height uint64) uint64

type FairPosCalculatorV2 added in v0.6.0

type FairPosCalculatorV2 struct {
}

func (*FairPosCalculatorV2) CalculateBaseTarget added in v0.6.0

func (calc *FairPosCalculatorV2) CalculateBaseTarget(
	targetBlockDelaySeconds uint64,
	confirmedHeight uint64,
	confirmedTarget uint64,
	confirmedTimestamp uint64,
	greatGrandParentTimestamp uint64,
	applyingBlockTimestamp uint64,
) (types.BaseTarget, error)

func (*FairPosCalculatorV2) CalculateDelay added in v0.6.0

func (calc *FairPosCalculatorV2) CalculateDelay(hit *Hit, confirmedTarget types.BaseTarget, balance uint64) (uint64, error)

func (*FairPosCalculatorV2) HeightForHit added in v0.6.0

func (calc *FairPosCalculatorV2) HeightForHit(height uint64) uint64

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 NXTGenerationSignatureProvider added in v0.5.0

type NXTGenerationSignatureProvider struct {
}

NXTGenerationSignatureProvider implements the original NXT way to create generation signature using generator's public key and generation signature from the previous block.

func (*NXTGenerationSignatureProvider) GenerationSignature added in v0.5.0

func (p *NXTGenerationSignatureProvider) GenerationSignature(key [crypto.KeySize]byte, msg []byte) ([]byte, error)

GenerationSignature builds NXT generation signature using only generator's public key.

func (*NXTGenerationSignatureProvider) HitSource added in v0.5.0

func (p *NXTGenerationSignatureProvider) HitSource(key [crypto.KeySize]byte, msg []byte) ([]byte, error)

func (*NXTGenerationSignatureProvider) VerifyGenerationSignature added in v0.5.0

func (p *NXTGenerationSignatureProvider) VerifyGenerationSignature(pk crypto.PublicKey, msg, sig []byte) (bool, []byte, error)

type NxtPosCalculator

type NxtPosCalculator struct {
}

func (*NxtPosCalculator) CalculateBaseTarget

func (calc *NxtPosCalculator) CalculateBaseTarget(
	targetBlockDelaySeconds uint64,
	prevHeight uint64,
	prevTarget uint64,
	parentTimestamp uint64,
	greatGrandParentTimestamp uint64,
	currentTimestamp uint64,
) (types.BaseTarget, error)

func (*NxtPosCalculator) CalculateDelay

func (calc *NxtPosCalculator) CalculateDelay(hit *Hit, parentTarget types.BaseTarget, balance uint64) (uint64, error)

func (*NxtPosCalculator) HeightForHit added in v0.5.0

func (calc *NxtPosCalculator) HeightForHit(height uint64) uint64

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

type VRFGenerationSignatureProvider added in v0.5.0

type VRFGenerationSignatureProvider struct {
}

VRFGenerationSignatureProvider implements generation of VRF pseudo-random value calculated from generation signature of previous block and generator's secret key.

func (*VRFGenerationSignatureProvider) GenerationSignature added in v0.5.0

func (p *VRFGenerationSignatureProvider) GenerationSignature(key [crypto.KeySize]byte, msg []byte) ([]byte, error)

func (*VRFGenerationSignatureProvider) HitSource added in v0.5.0

func (p *VRFGenerationSignatureProvider) HitSource(key [crypto.KeySize]byte, msg []byte) ([]byte, error)

func (*VRFGenerationSignatureProvider) VerifyGenerationSignature added in v0.5.0

func (p *VRFGenerationSignatureProvider) VerifyGenerationSignature(pk crypto.PublicKey, msg, sig []byte) (bool, []byte, error)

VerifyGenerationSignature checks that provided signature is valid against given generator's public key and message.

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, tm types.Time) (*Validator, error)

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) ValidateHeaders added in v0.9.0

func (cv *Validator) ValidateHeaders(headers []proto.BlockHeader, startHeight uint64) error

Jump to

Keyboard shortcuts

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