Documentation ¶
Index ¶
- func DisableLog()
- func UseLogger(logger btclog.Logger)
- type CPUMiner
- func (m *CPUMiner) AddMiningKey(miningAddr *btcec.PrivateKey) bool
- func (m *CPUMiner) CurrentBlock(h *chainhash.Hash) *btcutil.Block
- func (m *CPUMiner) GenerateNBlocks(n uint32) ([]*chainhash.Hash, error)
- func (m *CPUMiner) IsGenerating() bool
- func (m *CPUMiner) IsMining() bool
- func (m *CPUMiner) Notice(notification *blockchain.Notification)
- func (m *CPUMiner) NumWorkers() int32
- func (m *CPUMiner) SetNumWorkers(numWorkers int32)
- func (m *CPUMiner) Start()
- func (m *CPUMiner) Stop()
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
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 New ¶
New returns a new instance of a CPU miner for the provided configuration. Use Start to begin the mining process. See the documentation for CPUMiner type for more details.
func (*CPUMiner) AddMiningKey ¶
func (m *CPUMiner) AddMiningKey(miningAddr *btcec.PrivateKey) bool
func (*CPUMiner) GenerateNBlocks ¶
func (*CPUMiner) IsGenerating ¶
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) Notice ¶
func (m *CPUMiner) Notice(notification *blockchain.Notification)
func (*CPUMiner) NumWorkers ¶
func (*CPUMiner) SetNumWorkers ¶
type Config ¶
type Config struct { // ChainParams identifies which chain parameters the cpu miner is // associated with. ChainParams *chaincfg.Params // BlockTemplateGenerator identifies the instance to use in order to // generate block templates that the miner will attempt to solve. BlockTemplateGenerator *mining.BlkTmplGenerator // MiningAddrs is a list of payment addresses to use for the generated // blocks. Each generated block will randomly choose one of them. MiningAddrs []btcutil.Address SignAddress []btcutil.Address PrivKeys []*btcec.PrivateKey DisablePOWMining bool EnablePOWMining bool // ProcessBlock defines the function to call with any solved blocks. // It typically must run the provided block through the same set of // rules and handling as any other block coming from the network. ProcessBlock func(*btcutil.Block, blockchain.BehaviorFlags) (bool, error) // ConnectedCount defines the function to use to obtain how many other // peers the server is connected to. This is used by the automatic // persistent mining routine to determine whether or it should attempt // mining. This is useful because there is no point in mining when not // connected to any peers since there would no be anyone to send any // found blocks to. ConnectedCount func() int32 // IsCurrent defines the function to use to obtain whether or not the // block chain is current. This is used by the automatic persistent // mining routine to determine whether or it should attempt mining. // This is useful because there is no point in mining if the chain is // not current since any solved blocks would be on a side chain and and // up orphaned anyways. IsCurrent func() bool // call back to add priv key to .conf AppendPrivKey func(*btcec.PrivateKey) bool Generate bool }
Config is a descriptor containing the cpu miner configuration.