pow

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: LGPL-3.0 Imports: 14 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartMining

func StartMining(block *types.Block, seed uint64, min uint64, max uint64, result chan<- *types.Block, abort <-chan struct{},
	isNonceFound *int32, once *sync.Once, hashrate metrics.Meter, log *log.SeeleLog)

StartMining starts calculating the nonce for the block. seed is the random start value for the nonce min is the min number for the nonce per thread max is the max number for the nonce per thread result represents the founded nonce will be set in the result block abort is a channel by closing which you can stop mining isNonceFound is a flag to mark nonce is found by other threads hashrate is the average hashrate of miner

Types

type API

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

func (*API) GetHashrate

func (api *API) GetHashrate() uint64

GetHashrate returns the current hashrate for local CPU miner and remote miner.

func (*API) GetThreads

func (api *API) GetThreads() int

GetThreads returns the thread number of the miner engine

type Engine

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

Engine provides the consensus operations based on POW.

func NewEngine

func NewEngine(threads int) *Engine

func (*Engine) APIs

func (engine *Engine) APIs(chain consensus.ChainReader) []rpc.API

func (*Engine) Prepare

func (engine *Engine) Prepare(reader consensus.ChainReader, header *types.BlockHeader) error

func (*Engine) Seal

func (engine *Engine) Seal(reader consensus.ChainReader, block *types.Block, stop <-chan struct{}, results chan<- *types.Block) error

func (*Engine) SetThreads

func (engine *Engine) SetThreads(threads int)

func (*Engine) VerifyHeader

func (engine *Engine) VerifyHeader(reader consensus.ChainReader, header *types.BlockHeader) error

ValidateHeader validates the specified header and returns error if validation failed.

Jump to

Keyboard shortcuts

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