pow

package
v1.5.10-0...-6d038e7 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2017 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDumpMagic  = errors.New("invalid dump magic")
	ErrNonceOutOfRange   = errors.New("nonce out of range")
	ErrInvalidDifficulty = errors.New("non-positive difficulty")
	ErrInvalidMixDigest  = errors.New("invalid mix digest")
	ErrInvalidPoW        = errors.New("pow difficulty invalid")
)

Functions

func EthashSeedHash

func EthashSeedHash(block uint64) []byte

EthashSeedHash is the seed to use for generating a vrification cache and the mining dataset.

func MakeCache

func MakeCache(block uint64, dir string)

MakeCache generates a new ethash cache and optionally stores it to disk.

func MakeDataset

func MakeDataset(block uint64, dir string)

MakeDataset generates a new ethash dataset and optionally stores it to disk.

Types

type Block

type Block interface {
	Difficulty() *big.Int
	HashNoNonce() common.Hash
	Nonce() uint64
	MixDigest() common.Hash
	NumberU64() uint64
}

type ChainManager

type ChainManager interface {
	GetBlockByNumber(uint64) *types.Block
	CurrentBlock() *types.Block
}

type Ethash

type Ethash struct {
	// contains filtered or unexported fields
}

Ethash is a PoW data struture implementing the ethash algorithm.

func (*Ethash) Hashrate

func (ethash *Ethash) Hashrate() float64

Hashrate implements PoW, returning the measured rate of the search invocations per second over the last minute.

func (*Ethash) Search

func (ethash *Ethash) Search(block Block, stop <-chan struct{}) (uint64, []byte)

Search implements PoW, attempting to find a nonce that satisfies the block's difficulty requirements.

func (*Ethash) Verify

func (ethash *Ethash) Verify(block Block) error

Verify implements PoW, checking whether the given block satisfies the PoW difficulty requirements.

type FakePow

type FakePow struct{}

FakePow is a non-validating proof of work implementation. It returns true from Verify for any block.

func (FakePow) Hashrate

func (pow FakePow) Hashrate() float64

Hashrate implements PoW, returning 0.

func (FakePow) Search

func (pow FakePow) Search(block Block, stop <-chan struct{}) (uint64, []byte)

Search implements PoW, returning the nonce 0 for any call.

func (FakePow) Verify

func (pow FakePow) Verify(block Block) error

Verify implements PoW, returning a success for an input.

type PoW

type PoW interface {
	Verify(block Block) error
	Search(block Block, stop <-chan struct{}) (uint64, []byte)
	Hashrate() float64
}

func NewFullEthash

func NewFullEthash(cachedir string, cachesinmem, cachesondisk int, dagdir string, dagsinmem, dagsondisk int) PoW

NewFullEthash creates a full sized ethash PoW scheme.

func NewSharedEthash

func NewSharedEthash() PoW

NewSharedEthash creates a full sized ethash PoW shared between all requesters running in the same process.

func NewTestEthash

func NewTestEthash() PoW

NewTestEthash creates a small sized ethash PoW scheme useful only for testing purposes.

Jump to

Keyboard shortcuts

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