miner

package
v0.0.0-...-f58d8a1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: LGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMinerIsRunning is returned when miner is running
	ErrMinerIsRunning = errors.New("miner is running")

	// ErrMinerIsStopped is returned when miner is stopped
	ErrMinerIsStopped = errors.New("miner is stopped")

	// ErrNodeIsSyncing is returned when the node is syncing
	ErrNodeIsSyncing = errors.New("can not start miner when syncing")
)

Functions

func PrintableOutputTask

func PrintableOutputTask(task *Task) map[string]interface{}

PrintableOutputTask returns the printable format of task

func PrintableOutputTaskHeader

func PrintableOutputTaskHeader(header *types.BlockHeader, totalDifficulty *big.Int) map[string]interface{}

PrintableOutputTask returns the printable format of the task header

Types

type Miner

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

Miner defines base elements of miner

func NewMiner

func NewMiner(addr common.Address, addrList []common.Address, scdo ScdoBackend, verifier types.DebtVerifier, engine consensus.Engine, isPoolMode bool) *Miner

NewMiner constructs and returns a miner instance

func (*Miner) CanStart

func (miner *Miner) CanStart() bool

CanStart is true when the miner is stopped and stopper == 0 and canStart == 1

func (*Miner) GetCoinbase

func (miner *Miner) GetCoinbase() common.Address

GetCoinbase gets the coinbase

func (*Miner) GetCurrentWorkHeader

func (miner *Miner) GetCurrentWorkHeader(totalDifficulty *big.Int) map[string]interface{}

GetCurrentWorkHeader returns the header of current task

func (*Miner) GetEngine

func (miner *Miner) GetEngine() consensus.Engine

GetEngine gets the miner engine

func (*Miner) GetTaskDifficulty

func (miner *Miner) GetTaskDifficulty() *big.Int

GetTaskDifficulty gets the difficulty of current task

func (*Miner) GetWork

func (miner *Miner) GetWork() map[string]interface{}

GetWork get the current task in a printable format

func (*Miner) GetWorkTask

func (miner *Miner) GetWorkTask() *Task

GetWorkTask gets the current task

func (*Miner) IsMining

func (miner *Miner) IsMining() bool

IsMining returns true if the miner is started, otherwise false

func (*Miner) SetCoinbase

func (miner *Miner) SetCoinbase(coinbase common.Address)

SetCoinbase set the coinbase.

func (*Miner) SetGpuBlocksThreads

func (miner *Miner) SetGpuBlocksThreads(blocks int, threads int)

func (*Miner) SetStopper

func (miner *Miner) SetStopper(stopper int32)

SetStopper. If stopper is 1, miner won't do mining

func (*Miner) SetThreads

func (miner *Miner) SetThreads(threads int)

SetThreads sets the number of mining threads.

func (*Miner) Start

func (miner *Miner) Start() error

Start is used to start the miner

func (*Miner) Stop

func (miner *Miner) Stop()

Stop is used to stop the miner

func (*Miner) SubmitWork

func (miner *Miner) SubmitWork(height uint64, nonce uint64) error

SubmitWork is used to submit the nonce to generate the final block

type Result

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

Result is the result mined by engine. It contains the raw task and mined block.

type ScdoBackend

type ScdoBackend interface {
	TxPool() *core.TransactionPool
	BlockChain() *core.Blockchain
	DebtPool() *core.DebtPool
}

ScdoBackend wraps all methods required for miner.

type Task

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

Task is a mining work for engine, containing block header, transactions, and transaction receipts.

func NewTask

func NewTask(header *types.BlockHeader, coinbase common.Address, verifier types.DebtVerifier) *Task

NewTask return Task object

Jump to

Keyboard shortcuts

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