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 ¶
func New(s *consensus.State, g modules.Gateway, tpool modules.TransactionPool, w modules.Wallet) (m *Miner, err error)
New returns a ready-to-go miner that is not mining.
func (*Miner) Info ¶
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 ¶
SetThreads establishes how many threads the miner will use when mining.
func (*Miner) SolveBlock ¶
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 ¶
StartMining spawns a bunch of mining threads which will mine until stop is called.
func (*Miner) StopMining ¶
StopMining sets desiredThreads to 0, a value which is polled by mining threads. When set to 0, the mining threads will all cease mining.