Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Log = cl.NewSubSystem("chain/mining/dispatch", ll.DEFAULT)
Log is the logger for the peer package
Functions ¶
Types ¶
type Config ¶
type Config struct { // Blockchain gives access for the miner to information about the chain Blockchain *blockchain.BlockChain // 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 thec. MiningAddrs []util.Address // 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(*util.Block, blockchain.BehaviorFlags) (bool, error) // MinerListener is the listener that will accept miner subscriptions and such MinerListener string // MinerKey is generated from the password specified in the main configuration for miner port using Stribog hash to derive the nonce, Argon2i to expand the password, and a final pass of Keccak MinerKey []byte // 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 }
type Controller ¶
func New ¶
func New( cfg *Config) *Controller
New returns a new instance of a CPU miner for the provided configuration. Use Start to begin the mining process. See the documentation for Controller type for more details.
func (*Controller) IsMining ¶
func (c *Controller) IsMining() bool
IsMining returns whether or not the miner controller has been started and is therefore currenting mining. This function is safe for concurrent access.
func (*Controller) Start ¶
func (c *Controller) Start()
Start begins the miner controller process. Calling this function when the miner controller has already been started will have no effect.
func (*Controller) Stop ¶
func (c *Controller) Stop()
Stop gracefully stops the mining process by signalling all workers, and the speed monitor to quit. Calling this function when the miner controller has not already been started will have no effect.