difficulty

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2018 License: AGPL-3.0 Imports: 4 Imported by: 12

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

func CalcNextRequiredDifficulty

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

CalcNextRequiredDifficulty return the difficult for next block

func CheckProofOfWork

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

CheckProofOfWork the hash is vaild for given difficult

func CompactToBig

func CompactToBig(compact uint64) *big.Int

CompactToBig converts a compact representation of a whole number N to an unsigned 64-bit number. The representation is similar to IEEE754 floating point numbers.

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

N = (-1^sign) * mantissa * 256^(exponent-3)

func HashToBig

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

HashToBig convert bc.Hash to a difficult int

Types

This section is empty.

Jump to

Keyboard shortcuts

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