challenge

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: GPL-3.0 Imports: 4 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(parent *types.Header, referredHeaders []*types.Header) (*common.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