consensus

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsensusValidator

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

func NewConsensusValidator

func NewConsensusValidator(state stateInfoProvider, tm types.Time) (*ConsensusValidator, error)

func (*ConsensusValidator) RangeForGeneratingBalanceByHeight added in v0.5.0

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

func (*ConsensusValidator) ValidateHeaders

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

type FairPosCalculator

type FairPosCalculator struct {
}

func (*FairPosCalculator) CalculateBaseTarget

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

func (*FairPosCalculator) CalculateDelay

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

func (*FairPosCalculator) HeightForHit added in v0.5.0

func (calc *FairPosCalculator) 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)

Only generator's public key is used then building NXT generation signature.

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)

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

Jump to

Keyboard shortcuts

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