difficulty

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2016 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Implement the Bitcoin difficulty value and its various encodings

Index

Constants

View Source
const DefaultUint32 = 0x1d00ffff

the default uint32 value

View Source
const HalfLife = 100

number of block times to decay the difficulty by 50%

Variables

View Source
var Current = &Difficulty{
	filter: filters.NewCamm(1.0, 21, 41),
}

current difficulty

Functions

This section is empty.

Types

type Difficulty

type Difficulty struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Type for difficulty

func New

func New() *Difficulty

create a difficulty with the default value

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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