소스 검색

miner: start a newly registered agent if the miner is running. Closes #681

obscuren 10 년 전
부모
커밋
ec6cbb914b
2개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 2
      miner/miner.go
  2. 5 1
      miner/worker.go

+ 4 - 2
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 {

+ 5 - 1
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))
+			}
 		}
 	}
 }