Documentation ¶
Index ¶
- func UseLogger(logger l.Logger)
- type CPUMiner
- func (c *CPUMiner) APIs() []rpc.API
- func (m *CPUMiner) GenerateBlockByParents(parents []*hash.Hash) (*hash.Hash, error)
- func (m *CPUMiner) GenerateNBlocks(n uint32, powType pow.PowType) ([]*hash.Hash, error)
- func (m *CPUMiner) GetPolicy() *mining.Policy
- func (m *CPUMiner) GetSigCache() *txscript.SigCache
- func (m *CPUMiner) GetTimeSource() blockchain.MedianTimeSource
- func (m *CPUMiner) HashesPerSecond() float64
- func (m *CPUMiner) IsMining() bool
- func (m *CPUMiner) NumWorkers() int32
- func (m *CPUMiner) SetNumWorkers(numWorkers int32)
- func (m *CPUMiner) Start()
- func (m *CPUMiner) Stop()
- type PrivateMinerAPI
- type PublicMinerAPI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CPUMiner ¶
CPUMiner provides facilities for solving blocks (mining) using the CPU in a concurrency-safe manner. It consists of two main goroutines -- a speed monitor and a controller for worker goroutines which generate and solve blocks. The number of goroutines can be set via the SetMaxGoRoutines function, but the default is based on the number of processor cores in the system which is typically sufficient.
func NewCPUMiner ¶
func NewCPUMiner(cfg *config.Config, par *params.Params, policy *mining.Policy, cache *txscript.SigCache, source mining.TxSource, tsource blockchain.MedianTimeSource, blkMgr *blkmgr.BlockManager, numWorkers uint32) *CPUMiner
newCPUMiner returns a new instance of a CPU miner for the provided server. Use Start to begin the mining process. See the documentation for CPUMiner type for more details.
func (*CPUMiner) GenerateBlockByParents ¶
func (*CPUMiner) GenerateNBlocks ¶
GenerateNBlocks generates the requested number of blocks. It is self contained in that it creates block templates and attempts to solve them while detecting when it is performing stale work and reacting accordingly by generating a new block template. When a block is solved, it is submitted. The function returns a list of the hashes of generated blocks.
func (*CPUMiner) GetTimeSource ¶
func (m *CPUMiner) GetTimeSource() blockchain.MedianTimeSource
return time source
func (*CPUMiner) HashesPerSecond ¶
HashesPerSecond returns the number of hashes per second the mining process is performing. 0 is returned if the miner is not currently running.
This function is safe for concurrent access.
func (*CPUMiner) IsMining ¶
IsMining returns whether or not the CPU miner has been started and is therefore currenting mining.
This function is safe for concurrent access.
func (*CPUMiner) NumWorkers ¶
NumWorkers returns the number of workers which are running to solve blocks.
This function is safe for concurrent access.
func (*CPUMiner) SetNumWorkers ¶
SetNumWorkers sets the number of workers to create which solve blocks. Any negative values will cause a default number of workers to be used which is based on the number of processor cores in the system. A value of 0 will cause all CPU mining to be stopped.
This function is safe for concurrent access.
type PrivateMinerAPI ¶
type PrivateMinerAPI struct {
// contains filtered or unexported fields
}
PrivateMinerAPI provides private RPC methods to control the miner.
func NewPrivateMinerAPI ¶
func NewPrivateMinerAPI(c *CPUMiner) *PrivateMinerAPI
type PublicMinerAPI ¶
type PublicMinerAPI struct {
// contains filtered or unexported fields
}
func NewPublicMinerAPI ¶
func NewPublicMinerAPI(c *CPUMiner) *PublicMinerAPI
func (*PublicMinerAPI) GetBlockTemplate ¶
func (api *PublicMinerAPI) GetBlockTemplate(capabilities []string, powType byte) (interface{}, error)
func (api *PublicMinerAPI) GetBlockTemplate(request *mining.TemplateRequest) (interface{}, error){
func (*PublicMinerAPI) SubmitBlock ¶
func (api *PublicMinerAPI) SubmitBlock(hexBlock string) (interface{}, error)
LL Attempts to submit new block to network. See https://en.bitcoin.it/wiki/BIP_0022 for full specification