Documentation
¶
Index ¶
- type Miner
- func (m *Miner) Info() (components.MinerInfo, error)
- func (m *Miner) SolveBlock() (b consensus.Block, solved bool, err error)
- func (m *Miner) StartMining() error
- func (m *Miner) StopMining() error
- func (m *Miner) SubsidyAddress() consensus.CoinAddress
- func (m *Miner) Threads() int
- func (m *Miner) UpdateMiner(mu components.MinerUpdate) 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
}
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 ¶
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 ¶
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.
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) 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.