Documentation ¶
Index ¶
- type Miner
- func (m *Miner) BlockForWork() (types.Block, crypto.Hash, types.Target)
- func (m *Miner) FindBlock() (types.Block, bool, error)
- func (m *Miner) MinerInfo() modules.MinerInfo
- func (m *Miner) MinerNotify() <-chan struct{}
- func (m *Miner) ReceiveTransactionPoolUpdate(revertedBlocks, appliedBlocks []types.Block, ...)
- func (m *Miner) SetThreads(threads int) error
- func (m *Miner) SolveBlock(blockForWork types.Block, target types.Target) (b types.Block, solved bool)
- func (m *Miner) StartMining() error
- func (m *Miner) StopMining() error
- func (m *Miner) SubmitBlock(b types.Block) error
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(cs modules.ConsensusSet, tpool modules.TransactionPool, w modules.Wallet) (m *Miner, err error)
New returns a ready-to-go miner that is not mining.
func (*Miner) BlockForWork ¶ added in v0.3.2
BlockForWork returns a block that is ready for nonce grinding, along with the root hash of the block.
func (*Miner) FindBlock ¶ added in v0.3.1
FindBlock will attempt to solve a block and add it to the state. While less efficient than StartMining, it is guaranteed to find at most one block.
func (*Miner) MinerInfo ¶ added in v0.3.1
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) MinerNotify ¶ added in v0.3.1
func (m *Miner) MinerNotify() <-chan struct{}
MinerNotify adds a subscriber to the miner.
func (*Miner) ReceiveTransactionPoolUpdate ¶ added in v0.3.1
func (m *Miner) ReceiveTransactionPoolUpdate(revertedBlocks, appliedBlocks []types.Block, unconfirmedTransactions []types.Transaction, _ []modules.SiacoinOutputDiff)
ReceiveTransactionPoolUpdate listens to the transaction pool for changes in the transaction pool. These changes will be applied to the blocks being mined.
func (*Miner) SetThreads ¶
SetThreads establishes how many threads the miner will use when mining.
func (*Miner) SolveBlock ¶
func (m *Miner) SolveBlock(blockForWork types.Block, target types.Target) (b types.Block, solved bool)
SolveBlock attempts to solve a block, returning the solved block without submitting it to the state. This function is primarily to help with testing, and is very slow.
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.