frkhash

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: GPL-3.0 Imports: 27 Imported by: 1

README

go-frkhash

Frkhash go module intended for use by core-pool (and open-ethereum-pool).

usage (frkhash)
var ecip1099FBlockClassic uint64 = 11700000 // classic mainnet
var ecip1099FBlockMordor uint64 = 2520000 // mordor testnet

var hasher = frkhash.New(&ecip1099FBlockMordor, nil)

if hasher.Verify(block) {
    ...
}
usage (ethash)
var hasher = frkhash.New(nil, nil)

if hasher.Verify(block) {
    ...
}
usage (ubqhash)
var uip1FEpoch uint64 = 22 // ubiq mainnet

var hasher = frkhash.New(nil, &uip1FEpoch)

if hasher.Verify(block) {
    ...
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultDir = defaultDir()
View Source
var (
	ErrInvalidDumpMagic = errors.New("invalid dump magic")
)

Functions

func MakeDAG added in v1.0.5

func MakeDAG(block uint64, epochLength uint64, dir string)

MakeDAG generates a new frkhash 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 Frkhash

type Frkhash struct {
	*Light
	*Full
}

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

func New

func New(ecip1099FBlock *uint64, uip1FEpoch *uint64, xip5Block *uint64) *Frkhash

New creates an instance of the proof of work.

func NewForTesting added in v1.0.5

func NewForTesting(ecip1099FBlock *uint64, uip1FEpoch *uint64, xip5Block *uint64) (*Frkhash, 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 NewForTestingFrk added in v1.0.5

func NewForTestingFrk(xip5Block *uint64) *Frkhash

func NewShared

func NewShared(ecip1099FBlock *uint64, uip1FEpoch *uint64, xip5Block *uint64) *Frkhash

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 added in v1.0.5

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 added in v1.0.5

func (pow *Full) GetHashrate() int64

func (*Full) Search added in v1.0.5

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

func (*Full) SearchDag added in v1.0.5

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

func (*Full) SearchFrk added in v1.0.5

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

func (*Full) Turbo added in v1.0.5

func (pow *Full) Turbo(on bool)

type Light added in v1.0.5

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) Compute added in v1.0.5

func (l *Light) Compute(blockNum uint64, hashNoNonce common.Hash, nonce uint64) (mixDigest common.Hash, result common.Hash)

compute() to get mixhash and result

func (*Light) Verify added in v1.0.5

func (l *Light) Verify(block 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