Documentation ¶
Overview ¶
Package miner is responsible for creating and submitting siacoin blocks
Index ¶
- Variables
- type Miner
- func (m *Miner) AddBlock() (types.Block, error)
- func (m *Miner) Alerts() (crit, err, warn []modules.Alert)
- func (m *Miner) BlockForWork() (b types.Block, 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) Close() error
- func (m *Miner) FindBlock() (types.Block, error)
- func (m *Miner) HeaderForWork() (types.BlockHeader, types.Target, types.BlockHeight, error)
- func (m *Miner) HeaderForWorkWithBlockValue() (types.BlockHeader, types.Target, types.BlockHeight, types.Currency, error)
- func (m *Miner) ProcessConsensusChange(cc modules.ConsensusChange)
- func (m *Miner) ReceiveUpdatedUnconfirmedTransactions(diff *modules.TransactionPoolDiff)
- func (m *Miner) SolveBlock(b types.Block, target types.Target, height types.BlockHeight) (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 ¶
var ( // BlockMemory is the maximum number of blocks the miner will store // Blocks take up to 2 megabytes of memory, which is why this number is // limited. BlockMemory = build.Select(build.Var{ Standard: 50, Dev: 10, Testing: 5, }).(int) // HeaderMemory is the number of previous calls to 'header' // that are remembered. Additionally, 'header' will only poll for a // new block every 'headerMemory / blockMemory' times it is // called. This reduces the amount of memory used, but comes at the cost of // not always having the most recent transactions. HeaderMemory = build.Select(build.Var{ Standard: 10000, Dev: 500, Testing: 50, }).(int) // MaxSourceBlockAge is the maximum amount of time that is allowed to // elapse between generating source blocks. MaxSourceBlockAge = build.Select(build.Var{ Standard: 30 * time.Second, Dev: 5 * time.Second, Testing: 1 * time.Second, }).(time.Duration) )
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) Alerts ¶ added in v1.5.0
Alerts implements the modules.Alerter interface for the miner.
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 an estimated cpu hashrate.
func (*Miner) Close ¶ added in v1.0.0
Close terminates all ongoing processes involving the miner, enabling garbage collection.
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
func (m *Miner) HeaderForWork() (types.BlockHeader, types.Target, types.BlockHeight, error)
HeaderForWork returns a header that is ready for nonce grinding. The miner will store the header in memory for a while, depending on the constants 'HeaderMemory', 'BlockMemory', and 'MaxSourceBlockAge'. On the full network, it is typically safe to assume that headers will be remembered for min(10 minutes, 10e3 requests).
func (*Miner) HeaderForWorkWithBlockValue ¶ added in v1.9.3
func (m *Miner) HeaderForWorkWithBlockValue() (types.BlockHeader, types.Target, types.BlockHeight, types.Currency, error)
HeaderForWorkWithBlockValue returns a header that is ready for nonce grinding. The miner will store the header in memory for a while, depending on the constants 'HeaderMemory', 'BlockMemory', and 'MaxSourceBlockAge'. On the full network, it is typically safe to assume that headers will be remembered for min(10 minutes, 10e3 requests). It also includes block value, which includes all the coins sent to the miners.
func (*Miner) ProcessConsensusChange ¶ added in v1.0.0
func (m *Miner) ProcessConsensusChange(cc modules.ConsensusChange)
ProcessConsensusChange will update the miner's most recent block.
func (*Miner) ReceiveUpdatedUnconfirmedTransactions ¶ added in v1.0.0
func (m *Miner) ReceiveUpdatedUnconfirmedTransactions(diff *modules.TransactionPoolDiff)
ReceiveUpdatedUnconfirmedTransactions will replace the current unconfirmed set of transactions with the input transactions.
func (*Miner) SolveBlock ¶
func (m *Miner) SolveBlock(b types.Block, target types.Target, height types.BlockHeight) (types.Block, bool)
SolveBlock takes a block and a target and tries to solve the block for the target. A bool is returned indicating whether the block was successfully solved.
func (*Miner) StartCPUMining ¶ added in v1.0.0
func (m *Miner) StartCPUMining()
StartCPUMining will start a single threaded cpu miner. If the miner is already running, nothing will happen.
func (*Miner) StopCPUMining ¶ added in v1.0.0
func (m *Miner) StopCPUMining()
StopCPUMining will stop the cpu miner. If the cpu miner is already stopped, nothing will happen.
func (*Miner) SubmitBlock ¶ added in v0.3.2
SubmitBlock accepts a solved block.
func (*Miner) SubmitHeader ¶ added in v1.0.0
func (m *Miner) SubmitHeader(bh types.BlockHeader) error
SubmitHeader accepts a block header.