worker

package
v0.0.0-...-e495fa0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: GPL-3.0, LGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package miner implements SHX block creation and mining.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Miner

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

Miner creates blocks and searches for proof-of-work values.

func New

func New(config *config.ChainConfig, mux *sub.TypeMux, engine consensus.Engine, coinbase common.Address, db shxdb.Database) *Miner

func (*Miner) Mining

func (self *Miner) Mining() bool

func (*Miner) Pending

func (self *Miner) Pending() (*types.Block, *state.StateDB)

Pending returns the currently pending block and associated state.

func (*Miner) PendingBlock

func (self *Miner) PendingBlock() *types.Block

PendingBlock returns the currently pending block.

Note, to access both the pending block and the pending state simultaneously, please use Pending(), as the pending state can change between multiple method calls

func (*Miner) SetExtra

func (self *Miner) SetExtra(extra []byte) error

func (*Miner) SetOpt

func (self *Miner) SetOpt(maxtxs, peorid int)

func (*Miner) Start

func (self *Miner) Start(coinbase common.Address)

func (*Miner) Stop

func (self *Miner) Stop()

func (*Miner) WorkControl

func (self *Miner) WorkControl()

update keeps track of the synctrl events. Please be aware that this is a one shot type of update loop. It's entered once and as soon as `Done` or `Failed` has been broadcasted the events are unregistered and the loop is exited. This to prevent a major security vuln where external parties can DOS you with blocks and halt your mining operation for as long as the DOS continues.

type RoundState

type RoundState byte
const (
	IDLE RoundState = iota
	PostMining
	Mining
)

type Work

type Work struct {
	Block *types.Block // the new block
	// contains filtered or unexported fields
}

Work is the workers current environment and holds all of the current state information

func (*Work) WorkEnded

func (w *Work) WorkEnded(succeed bool)

type WorkPending

type WorkPending struct {
	Pending []*Work
	// contains filtered or unexported fields
}

func NewWorkPending

func NewWorkPending() *WorkPending

func (*WorkPending) Add

func (p *WorkPending) Add(w *Work) bool

func (*WorkPending) Empty

func (p *WorkPending) Empty() bool

func (*WorkPending) HaveErr

func (p *WorkPending) HaveErr() bool

func (*WorkPending) Head

func (p *WorkPending) Head() *Work

func (*WorkPending) Run

func (p *WorkPending) Run()

func (*WorkPending) SetNoError

func (p *WorkPending) SetNoError()

func (*WorkPending) Top

func (p *WorkPending) Top() *Work

Jump to

Keyboard shortcuts

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