diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-14 00:23:09 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-14 00:23:09 +0800 |
commit | 8a0f23915e4feb9aabe21bd075416bc0f32bbc43 (patch) | |
tree | 8f7dc62676e519236b69a977c7af00d81b1e0406 /miner/agent.go | |
parent | 8305d409d2ca83583d9fa7e837ec0a46ce6ba78e (diff) | |
download | dexon-8a0f23915e4feb9aabe21bd075416bc0f32bbc43.tar.gz dexon-8a0f23915e4feb9aabe21bd075416bc0f32bbc43.tar.zst dexon-8a0f23915e4feb9aabe21bd075416bc0f32bbc43.zip |
Fixed a few issues in the miner and updated hash rate title
* Sometimes old nonces were set by "old" agents
* Added the hash rate to the miner
Diffstat (limited to 'miner/agent.go')
-rw-r--r-- | miner/agent.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/miner/agent.go b/miner/agent.go index b12b9da4d..ddd8e6675 100644 --- a/miner/agent.go +++ b/miner/agent.go @@ -9,7 +9,7 @@ type CpuMiner struct { c chan *types.Block quit chan struct{} quitCurrentOp chan struct{} - returnCh chan<- []byte + returnCh chan<- Work index int pow pow.PoW @@ -28,9 +28,9 @@ func NewCpuMiner(index int, pow pow.PoW) *CpuMiner { return miner } -func (self *CpuMiner) Work() chan<- *types.Block { return self.c } -func (self *CpuMiner) Pow() pow.PoW { return self.pow } -func (self *CpuMiner) SetNonceCh(ch chan<- []byte) { self.returnCh = ch } +func (self *CpuMiner) Work() chan<- *types.Block { return self.c } +func (self *CpuMiner) Pow() pow.PoW { return self.pow } +func (self *CpuMiner) SetNonceCh(ch chan<- Work) { self.returnCh = ch } func (self *CpuMiner) Stop() { close(self.quit) @@ -42,7 +42,6 @@ out: for { select { case block := <-self.c: - minerlogger.Infof("miner[%d] got block\n", self.index) // make sure it's open self.quitCurrentOp <- struct{}{} @@ -66,9 +65,9 @@ done: } func (self *CpuMiner) mine(block *types.Block) { - minerlogger.Infof("started agent[%d]. mining...\n", self.index) + minerlogger.Infof("(re)started agent[%d]. mining...\n", self.index) nonce := self.pow.Search(block, self.quitCurrentOp) if nonce != nil { - self.returnCh <- nonce + self.returnCh <- Work{block.Number().Uint64(), nonce} } } |