Documentation ¶
Index ¶
- type Miner
- func (m *Miner) AddBlock() (types.Block, error)
- func (m *Miner) BlockForWork() (b types.Block, merkleRoot crypto.Hash, t types.Target, err error)
- func (m *Miner) BlocksMined() (goodBlocks, staleBlocks int)
- func (m *Miner) CPUHashrate() int
- func (m *Miner) CPUMining() bool
- func (m *Miner) FindBlock() (types.Block, error)
- func (m *Miner) HeaderForWork() (types.BlockHeader, types.Target, error)
- func (m *Miner) ProcessConsensusChange(cc modules.ConsensusChange)
- func (m *Miner) ReceiveUpdatedUnconfirmedTransactions(unconfirmedTransactions []types.Transaction, _ modules.ConsensusChange)
- func (m *Miner) SolveBlock(b types.Block, target types.Target) (types.Block, bool)
- func (m *Miner) StartCPUMining()
- func (m *Miner) StopCPUMining()
- func (m *Miner) SubmitBlock(b types.Block) error
- func (m *Miner) SubmitHeader(bh types.BlockHeader) 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
}
Miner struct contains all variables the miner needs in order to create and submit blocks.
func New ¶
func New(cs modules.ConsensusSet, tpool modules.TransactionPool, w modules.Wallet, persistDir string) (*Miner, 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) BlocksMined ¶ added in v1.0.0
BlocksMined returns the number of good blocks and stale blocks that have been mined by the miner.
func (*Miner) CPUHashrate ¶ added in v1.0.0
CPUHashrate returns the cpu hashrate.
func (*Miner) FindBlock ¶ added in v0.3.1
FindBlock finds at most one block that extends the current blockchain.
func (*Miner) HeaderForWork ¶ added in v1.0.0
HeaderForWork returns a block that is ready for nonce grinding, along with the root hash of the block.
func (*Miner) ProcessConsensusChange ¶ added in v1.0.0
func (m *Miner) ProcessConsensusChange(cc modules.ConsensusChange)
ProcessConsensusChange will update the miner's most recent block. This is a part of the ConsensusSetSubscriber interface.
func (*Miner) ReceiveUpdatedUnconfirmedTransactions ¶ added in v1.0.0
func (m *Miner) ReceiveUpdatedUnconfirmedTransactions(unconfirmedTransactions []types.Transaction, _ modules.ConsensusChange)
ReceiveUpdatedUnconfirmedTransactions will replace the current unconfirmed set of transactions with the input transactions. This is a part of the TransactionPoolSubscriber interface.
func (*Miner) SolveBlock ¶
SolveBlock takes a block, target, and number of iterations as input and tries to find a block that meets the target. This function can take a long time to complete, and should not be called with a lock.
func (*Miner) StartCPUMining ¶ added in v1.0.0
func (m *Miner) StartCPUMining()
StartMining will spawn a thread to begin mining. The thread will only start mining if there is not another thread mining yet.
func (*Miner) StopCPUMining ¶ added in v1.0.0
func (m *Miner) StopCPUMining()
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) SubmitBlock ¶ added in v0.3.2
submitBlock takes a solved block and submits it to the blockchain. submitBlock should not be called with a lock.
func (*Miner) SubmitHeader ¶ added in v1.0.0
func (m *Miner) SubmitHeader(bh types.BlockHeader) error
submitBlock takes a solved block and submits it to the blockchain. submitBlock should not be called with a lock.