miner

package
v0.0.0-...-e0c2429 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package miner provides a basic miner for sunyata, suitable for testing and as a basis for more sophisticated implementations.

Index

Constants

This section is empty.

Variables

View Source
var CPU cpuGrinder

CPU grinds nonces with a single CPU thread.

Functions

This section is empty.

Types

type Miner

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

A Miner mines blocks.

func New

func New(cs consensus.State, addr sunyata.Address, tp *txpool.Pool, ng NonceGrinder) *Miner

New returns a Miner initialized with the provided state.

func (*Miner) MineBlock

func (m *Miner) MineBlock() sunyata.Block

MineBlock mines a valid block, using transactions drawn from the txpool.

func (*Miner) ProcessChainApplyUpdate

func (m *Miner) ProcessChainApplyUpdate(cau *chain.ApplyUpdate, _ bool) error

ProcessChainApplyUpdate implements chain.Subscriber.

func (*Miner) ProcessChainRevertUpdate

func (m *Miner) ProcessChainRevertUpdate(cru *chain.RevertUpdate) error

ProcessChainRevertUpdate implements chain.Subscriber.

func (*Miner) Stats

func (m *Miner) Stats() (mined int, rate float64)

Stats reports various mining statistics.

type NonceGrinder

type NonceGrinder interface {
	GrindNonce(h *sunyata.BlockHeader, target sunyata.BlockID)
}

A NonceGrinder sets the value of h.Nonce such that h.ID().MeetsTarget(target) returns true.

Jump to

Keyboard shortcuts

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