miner

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2015 License: MIT Imports: 6 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
}

TODO: integrate the miner as a state listener.

func New

func New() (m *Miner)

New returns a miner that needs to be updated/initialized.

TODO: Formalize components so that

func (*Miner) Info

func (m *Miner) Info() (components.MinerInfo, error)

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) SolveBlock

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

SolveBlock grabs a block from the miner and grinds on the block, trying to find a winning solution.

SolveBlock locks the miner for long enough to grab a block, and then unlocks the miner for the remaining work, which does not interact with the miner.

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) SubsidyAddress

func (m *Miner) SubsidyAddress() consensus.CoinAddress

SubsidyAddress returns the address that is currently being used by the miner while searching for blocks.

func (*Miner) Threads

func (m *Miner) Threads() int

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

func (*Miner) UpdateMiner

func (m *Miner) UpdateMiner(mu components.MinerUpdate) error

TODO: write docstring.

TODO: contemplate giving the miner access to a read only state that it queries for block information, instead of needing to pass all of that information through the update struct.

Jump to

Keyboard shortcuts

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