miner: start a newly registered agent if the miner is running. Closes #681
This commit is contained in:
parent
52c874a609
commit
ec6cbb914b
@ -48,14 +48,16 @@ func (self *Miner) Start(coinbase common.Address) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *Miner) Register(agent Agent) {
|
func (self *Miner) Register(agent Agent) {
|
||||||
|
if self.mining {
|
||||||
|
agent.Start()
|
||||||
|
}
|
||||||
|
|
||||||
self.worker.register(agent)
|
self.worker.register(agent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Miner) Stop() {
|
func (self *Miner) Stop() {
|
||||||
self.mining = false
|
self.mining = false
|
||||||
self.worker.stop()
|
self.worker.stop()
|
||||||
|
|
||||||
//self.pow.(*ethash.Ethash).Stop()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Miner) HashRate() int64 {
|
func (self *Miner) HashRate() int64 {
|
||||||
|
@ -225,7 +225,11 @@ func (self *worker) push() {
|
|||||||
for _, agent := range self.agents {
|
for _, agent := range self.agents {
|
||||||
atomic.AddInt64(&self.atWork, 1)
|
atomic.AddInt64(&self.atWork, 1)
|
||||||
|
|
||||||
|
if agent.Work() != nil {
|
||||||
agent.Work() <- self.current.block.Copy()
|
agent.Work() <- self.current.block.Copy()
|
||||||
|
} else {
|
||||||
|
common.Report(fmt.Sprintf("%v %T\n", agent, agent))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user