challenge

package
v0.0.0-...-43c3cf5 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// New challenge is calculated based on 10 blocks before.
	ChallengeInterval = 10
	MaxReferredBlocks = ChallengeInterval * 2
)

Variables

This section is empty.

Functions

func CalcNextChallenge

func CalcNextChallenge(lastHeader *wire.BlockHeader, referredHeaders []*wire.BlockHeader) (*wire.Hash, error)

calcNextChallenge calculates the required challenge for the block after the passed previous block node based on the challenge adjustment rules. This function differs from the exported CalcNextChallenge in that, the exported version uses the current best chain as the previous block node while this function accepts any block node.

The calculation of next challenge accords to rules as followed:

  1. If the best block height ranges in [0, <ChallengeInterval>), then we use the block hash of last block as next Challenge.

  2. Else we calc (M = <best block height> mod <ChallengeInterval>), operating M times of Hash function to proof hash of certain block, use the result as next Challenge.

Types

This section is empty.

Jump to

Keyboard shortcuts

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