aboutsummaryrefslogtreecommitdiffstats
path: root/miner/agent.go
diff options
context:
space:
mode:
Diffstat (limited to 'miner/agent.go')
-rw-r--r--miner/agent.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/miner/agent.go b/miner/agent.go
index 64491e04c..d2e2e89bd 100644
--- a/miner/agent.go
+++ b/miner/agent.go
@@ -1,6 +1,7 @@
package miner
import (
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/pow"
)
@@ -9,7 +10,7 @@ type CpuMiner struct {
c chan *types.Block
quit chan struct{}
quitCurrentOp chan struct{}
- returnCh chan<- Work
+ returnCh chan<- *types.Block
index int
pow pow.PoW
@@ -24,9 +25,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) SetWorkCh(ch chan<- Work) { 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) SetReturnCh(ch chan<- *types.Block) { self.returnCh = ch }
func (self *CpuMiner) Stop() {
close(self.quit)
@@ -74,9 +75,12 @@ done:
func (self *CpuMiner) mine(block *types.Block) {
minerlogger.Infof("(re)started agent[%d]. mining...\n", self.index)
- nonce, mixDigest, seedHash := self.pow.Search(block, self.quitCurrentOp)
+ nonce, mixDigest, _ := self.pow.Search(block, self.quitCurrentOp)
if nonce != 0 {
- self.returnCh <- Work{block.Number().Uint64(), nonce, mixDigest, seedHash}
+ block.SetNonce(nonce)
+ block.Header().MixDigest = common.BytesToHash(mixDigest)
+ self.returnCh <- block
+ //self.returnCh <- Work{block.Number().Uint64(), nonce, mixDigest, seedHash}
}
}