ethash

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2017 License: MIT Imports: 18 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDir = defaultDir()
View Source
var Instance = New()

Functions

func GetSeedHash

func GetSeedHash(blockNum uint64) ([]byte, error)

func MakeDAG

func MakeDAG(blockNum uint64, dir string) error

MakeDAG pre-generates a DAG file for the given block number in the given directory. If dir is the empty string, the default directory is used.

func MakeDAGWithSize

func MakeDAGWithSize(blockNum uint64, dir string) (uint64, error)

Types

type Ethash

type Ethash struct {
	*Light
	*Full
}

Ethash combines block verification with Light and nonce searching with Full into a single proof of work.

func New

func New() *Ethash

New creates an instance of the proof of work.

func NewForTesting

func NewForTesting() (*Ethash, error)

NewForTesting creates a proof of work for use in unit tests. It uses a smaller DAG and cache size to keep test times low. DAG files are stored in a temporary directory.

Nonces found by a testing instance are not verifiable with a regular-size cache.

func NewShared

func NewShared() *Ethash

NewShared creates an instance of the proof of work., where a single instance of the Light cache is shared across all instances created with NewShared.

type Full

type Full struct {
	Dir string // use this to specify a non-default DAG directory
	// contains filtered or unexported fields
}

Full implements the Search half of the proof of work.

func (*Full) GetHashrate

func (pow *Full) GetHashrate() int64

func (*Full) Search

func (pow *Full) Search(block pow.Block, stop <-chan struct{}, index int) (nonce uint64, mixDigest []byte)

func (*Full) Turbo

func (pow *Full) Turbo(on bool)

type Light

type Light struct {
	NumCaches int // Maximum number of caches to keep before eviction (only init, don't modify)
	// contains filtered or unexported fields
}

Light implements the Verify half of the proof of work. It uses a few small in-memory caches to verify the nonces found by Full.

func (*Light) GetVerificationIndices

func (l *Light) GetVerificationIndices(block pow.Block) []uint32

func (*Light) SolutionState

func (l *Light) SolutionState(block pow.Block, shareDifficulty *big.Int) int

func (*Light) Verify

func (l *Light) Verify(block pow.Block) bool

Verify checks whether the block's nonce is valid.

Jump to

Keyboard shortcuts

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