diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-04 00:55:29 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-04 00:55:29 +0800 |
commit | 53b5a45856c5d4c307dc55b4ae1b46efd9471142 (patch) | |
tree | 56eb1f936610cc461742d2bb08431e304870e85a /miner | |
parent | b0aaa77f0213cb525a873c3bea92e8a06cff423f (diff) | |
parent | 313fe3861b3c338b3b6304adac46c86af7e2d52e (diff) | |
download | dexon-53b5a45856c5d4c307dc55b4ae1b46efd9471142.tar dexon-53b5a45856c5d4c307dc55b4ae1b46efd9471142.tar.gz dexon-53b5a45856c5d4c307dc55b4ae1b46efd9471142.tar.bz2 dexon-53b5a45856c5d4c307dc55b4ae1b46efd9471142.tar.lz dexon-53b5a45856c5d4c307dc55b4ae1b46efd9471142.tar.xz dexon-53b5a45856c5d4c307dc55b4ae1b46efd9471142.tar.zst dexon-53b5a45856c5d4c307dc55b4ae1b46efd9471142.zip |
Merge branch 'xcthulhu-publictests' into poc-9
Diffstat (limited to 'miner')
-rw-r--r-- | miner/agent.go | 4 | ||||
-rw-r--r-- | miner/miner.go | 9 | ||||
-rw-r--r-- | miner/worker.go | 10 |
3 files changed, 16 insertions, 7 deletions
diff --git a/miner/agent.go b/miner/agent.go index 9046f5d5a..5b2bfdb06 100644 --- a/miner/agent.go +++ b/miner/agent.go @@ -69,8 +69,8 @@ done: func (self *CpuMiner) mine(block *types.Block) { minerlogger.Infof("(re)started agent[%d]. mining...\n", self.index) - nonce := self.pow.Search(block, self.quitCurrentOp) + nonce, mixDigest, seedHash := self.pow.Search(block, self.quitCurrentOp) if nonce != nil { - self.returnCh <- Work{block.Number().Uint64(), nonce} + self.returnCh <- Work{block.Number().Uint64(), nonce, mixDigest, seedHash} } } diff --git a/miner/miner.go b/miner/miner.go index 0cc2361c8..f207948a5 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -5,7 +5,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/pow/ezp" + "github.com/ethereum/go-ethereum/pow" ) var minerlogger = logger.NewLogger("MINER") @@ -18,16 +18,19 @@ type Miner struct { Coinbase []byte mining bool + + pow pow.PoW } -func New(coinbase []byte, eth core.Backend, minerThreads int) *Miner { +func New(coinbase []byte, eth core.Backend, pow pow.PoW, minerThreads int) *Miner { miner := &Miner{ Coinbase: coinbase, worker: newWorker(coinbase, eth), + pow: pow, } for i := 0; i < minerThreads; i++ { - miner.worker.register(NewCpuMiner(i, ezp.New())) + miner.worker.register(NewCpuMiner(i, miner.pow)) } return miner diff --git a/miner/worker.go b/miner/worker.go index 4f0909302..fe80b63ee 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -42,8 +42,10 @@ func env(block *types.Block, eth core.Backend) *environment { } type Work struct { - Number uint64 - Nonce []byte + Number uint64 + Nonce []byte + MixDigest []byte + SeedHash []byte } type Agent interface { @@ -138,9 +140,13 @@ out: func (self *worker) wait() { for { for work := range self.recv { + // Someone Successfully Mined! block := self.current.block if block.Number().Uint64() == work.Number && block.Nonce() == nil { self.current.block.Header().Nonce = work.Nonce + self.current.block.Header().MixDigest = work.MixDigest + self.current.block.Header().SeedHash = work.SeedHash + fmt.Println(self.current.block) if err := self.chain.InsertChain(types.Blocks{self.current.block}); err == nil { self.mux.Post(core.NewMinedBlockEvent{self.current.block}) |