Documentation ¶
Overview ¶
Implement the Bitcoin difficulty value and its various encodings
Index ¶
- Constants
- Variables
- type Difficulty
- func (difficulty *Difficulty) Adjust(expectedMinutes float64, actualMinutes float64) float64
- func (difficulty *Difficulty) BigInt() *big.Int
- func (difficulty *Difficulty) Bits() uint32
- func (difficulty *Difficulty) Decay() float64
- func (difficulty *Difficulty) GoString() string
- func (difficulty *Difficulty) Pdiff() float64
- func (difficulty *Difficulty) SetBits(u uint32) *Difficulty
- func (difficulty *Difficulty) SetBytes(b []byte) *Difficulty
- func (difficulty *Difficulty) SetPdiff(f float64)
- func (difficulty *Difficulty) String() string
Constants ¶
const DefaultUint32 = 0x1d00ffff
the default uint32 value
const HalfLife = 100
number of block times to decay the difficulty by 50%
Variables ¶
var Current = &Difficulty{ filter: filters.NewCamm(1.0, 21, 41), }
current difficulty
Functions ¶
This section is empty.
Types ¶
type Difficulty ¶
Type for difficulty
func (*Difficulty) Adjust ¶
func (difficulty *Difficulty) Adjust(expectedMinutes float64, actualMinutes float64) float64
adjustment based on error from desired cycle time call as difficulty.Adjust(expectedMinutes, actualMinutes)
func (*Difficulty) BigInt ¶
func (difficulty *Difficulty) BigInt() *big.Int
convert a uint32 difficulty value to a big.Int
func (*Difficulty) Bits ¶
func (difficulty *Difficulty) Bits() uint32
Get difficulty as short packed value
func (*Difficulty) Decay ¶
func (difficulty *Difficulty) Decay() float64
exponential decay of difficulty call each expected block period to decay the current difficulty
func (*Difficulty) GoString ¶
func (difficulty *Difficulty) GoString() string
for the %#v format use 256 bit value
func (*Difficulty) Pdiff ¶
func (difficulty *Difficulty) Pdiff() float64
Get 1/difficulty as normal floating-point value this is the Pdiff value
func (*Difficulty) SetBits ¶
func (difficulty *Difficulty) SetBits(u uint32) *Difficulty
set from a 32 bit word (bits)
func (*Difficulty) SetBytes ¶
func (difficulty *Difficulty) SetBytes(b []byte) *Difficulty
func (*Difficulty) SetPdiff ¶
func (difficulty *Difficulty) SetPdiff(f float64)
func (*Difficulty) String ¶
func (difficulty *Difficulty) String() string
Get difficulty as the big endian hex encodes short packed value