difficulty

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigToCompact

func BigToCompact(n *big.Int) uint64

BigToCompact converts a whole number N to a compact representation using an unsigned 64-bit number. Sign is not really being used, but it's kept here.

func CalcNextRequiredDifficulty

func CalcNextRequiredDifficulty(lastBH, compareBH *types.BlockHeader) uint64

CalcNextRequiredDifficulty return the difficulty using compact representation for next block, when a lower difficulty Int actually reflects a more difficult mining progress.

func CalcWork added in v0.4.3

func CalcWork(bits uint64) *big.Int

CalcWork calculates a work value from difficulty bits.

func CheckProofOfWork

func CheckProofOfWork(hash, seed *bc.Hash, bits uint64) bool

CheckProofOfWork checks whether the hash is valid for a given difficulty.

func CompactToBig

func CompactToBig(compact uint64) *big.Int

CompactToBig converts a compact representation of a whole unsigned integer N to an big.Int. The representation is similar to IEEE754 floating point numbers. Sign is not really being used.

	-------------------------------------------------
	|   Exponent     |    Sign    |    Mantissa     |
	-------------------------------------------------
	| 8 bits [63-56] | 1 bit [55] | 55 bits [54-00] |
	-------------------------------------------------

	N = (-1^sign) * mantissa * 256^(exponent-3)
 Actually it will be nicer to use 7 instead of 3 for robustness reason.

func HashToBig

func HashToBig(hash *bc.Hash) *big.Int

HashToBig convert bc.Hash to a difficulty int

Types

This section is empty.

Jump to

Keyboard shortcuts

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