miner

package
v0.1.8-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2019 License: GPL-3.0 Imports: 21 Imported by: 2

Documentation

Overview

Package miner provides proof-of-work mining capability

Index

Constants

View Source
const (
	// EventWorkerFoundBlock indicates that a worker found a block
	EventWorkerFoundBlock = "event.workerFoundBlock"

	// HashrateMAWindow is the moving average window
	// within which ticks are collected to calculate
	// the average hashrate
	HashrateMAWindow = 5 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FoundBlock

type FoundBlock struct {
	WorkerID int
	Block    types.Block
	Nonce    uint64
	Started  time.Time
	Finished time.Time
}

FoundBlock represents a block with a valid nonce

type Miner

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

Miner provides proof-of-work computation, difficulty calculation and prepares a mine block for processing.

func NewMiner

func NewMiner(mineKey *crypto.Key, blockMaker types.BlockMaker,
	event *emitter.Emitter, cfg *config.EngineConfig,
	log logger.Logger) *Miner

NewMiner creates a Miner instance

func (*Miner) APIs

func (m *Miner) APIs() jsonrpc.APISet

APIs returns all API handlers

func (*Miner) Begin

func (m *Miner) Begin() error

Begin starts proof-of-work computation and all managing functions

func (*Miner) RestartWorkers

func (m *Miner) RestartWorkers() error

RestartWorkers restarts workers. Any previous task is immediately dropped and a new block is proposed and worked on

func (*Miner) SetNumThreads

func (m *Miner) SetNumThreads(n int)

SetNumThreads sets the number of threads performing PoW computation

func (*Miner) Stop

func (m *Miner) Stop()

Stop the miner

type Worker

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

Worker performs proof-of-work computation

func (*Worker) Stop

func (w *Worker) Stop()

Stop the worker

Directories

Path Synopsis
Package blakimoto provides functionalities for performing and verifying proof-of-work computation.
Package blakimoto provides functionalities for performing and verifying proof-of-work computation.

Jump to

Keyboard shortcuts

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