From ec6cbb914b4e3070ad2fd6194c2fa6de2c1080cc Mon Sep 17 00:00:00 2001 From: obscuren Date: Wed, 15 Apr 2015 17:04:22 +0200 Subject: [PATCH] miner: start a newly registered agent if the miner is running. Closes #681 --- miner/miner.go | 6 ++++-- miner/worker.go | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/miner/miner.go b/miner/miner.go index aa6c059ba..a14a195d2 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -48,14 +48,16 @@ func (self *Miner) Start(coinbase common.Address) { } func (self *Miner) Register(agent Agent) { + if self.mining { + agent.Start() + } + self.worker.register(agent) } func (self *Miner) Stop() { self.mining = false self.worker.stop() - - //self.pow.(*ethash.Ethash).Stop() } func (self *Miner) HashRate() int64 { diff --git a/miner/worker.go b/miner/worker.go index 916481973..9fb248efa 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -225,7 +225,11 @@ func (self *worker) push() { for _, agent := range self.agents { atomic.AddInt64(&self.atWork, 1) - agent.Work() <- self.current.block.Copy() + if agent.Work() != nil { + agent.Work() <- self.current.block.Copy() + } else { + common.Report(fmt.Sprintf("%v %T\n", agent, agent)) + } } } }