miner

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

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
}

func New

New returns a ready-to-go miner that is not mining.

func (*Miner) Info

func (m *Miner) Info() MinerInfo

Info() returns a MinerInfo struct which can be converted to JSON to be parsed by frontends for displaying information to the user.

State is a string indicating what the miner is currently doing with respect to the number of threads it currently has vs. the number of threads it wants to have.

Threads is the number of threads that the miner currently wants to have.

RunningThreads is the number of threads that the miner currently has.

Address is the current address that is receiving block payouts.

func (*Miner) SetThreads

func (m *Miner) SetThreads(threads int) error

SetThreads establishes how many threads the miner will use when mining.

func (*Miner) SolveBlock

func (m *Miner) SolveBlock() (consensus.Block, bool, error)

SolveBlock is an exported function which will attempt to solve a block to add to the state. SolveBlock is less efficient than StartMining(), but is guaranteed to solve at most one block (useful for testing).

solveBlock is both blocking and takes a long time to complete, therefore needs to be called without the miner being locked. For this reason, SolveBlock breaks typical mutex conventions and unlocks before returning.

func (*Miner) StartMining

func (m *Miner) StartMining() error

StartMining spawns a bunch of mining threads which will mine until stop is called.

func (*Miner) StopMining

func (m *Miner) StopMining() error

StopMining sets desiredThreads to 0, a value which is polled by mining threads. When set to 0, the mining threads will all cease mining.

func (*Miner) Threads

func (m *Miner) Threads() int

Threads returns the number of threads being used by the miner.

type MinerInfo

type MinerInfo struct {
	State          string
	Mining         bool
	Threads        int
	RunningThreads int
	Address        consensus.UnlockHash
}

MinerStatus is the information that gets returned to the front end. Each item is returned in the format that it's meant to be displayed.

Jump to

Keyboard shortcuts

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