diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-04 19:46:33 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-04 19:46:33 +0800 |
commit | 699dcaf65ced99517724984f5930845417cfdfca (patch) | |
tree | 36bdb1d1c992924750088b431cac94566df443cd /miner | |
parent | f4b717cb9da6113304f243caea6a3799a1aeecf3 (diff) | |
download | go-tangerine-699dcaf65ced99517724984f5930845417cfdfca.tar go-tangerine-699dcaf65ced99517724984f5930845417cfdfca.tar.gz go-tangerine-699dcaf65ced99517724984f5930845417cfdfca.tar.bz2 go-tangerine-699dcaf65ced99517724984f5930845417cfdfca.tar.lz go-tangerine-699dcaf65ced99517724984f5930845417cfdfca.tar.xz go-tangerine-699dcaf65ced99517724984f5930845417cfdfca.tar.zst go-tangerine-699dcaf65ced99517724984f5930845417cfdfca.zip |
Reworked chain handling process
* Forks
* Rename
* Moved inserting of blocks & processing
* Added chain testing method for validating pieces of a **a** chain.
Diffstat (limited to 'miner')
-rw-r--r-- | miner/miner.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/miner/miner.go b/miner/miner.go index fd74da4d1..7491ab373 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -162,8 +162,9 @@ func (miner *Miner) stopMining() { func (self *Miner) mineNewBlock() { blockManager := self.ethereum.BlockManager() + chainMan := self.ethereum.ChainManager() - self.block = self.ethereum.ChainManager().NewBlock(self.coinbase) + self.block = chainMan.NewBlock(self.coinbase) // Apply uncles if len(self.uncles) > 0 { @@ -199,10 +200,12 @@ func (self *Miner) mineNewBlock() { nonce := self.pow.Search(self.block, self.powQuitChan) if nonce != nil { self.block.Nonce = nonce - err := self.ethereum.BlockManager().Process(self.block) + lchain := chain.NewChain(chain.Blocks{self.block}) + _, err := chainMan.TestChain(lchain) if err != nil { minerlogger.Infoln(err) } else { + self.ethereum.ChainManager().InsertChain(lchain) self.ethereum.Broadcast(wire.MsgBlockTy, []interface{}{self.block.Value().Val}) minerlogger.Infof("🔨 Mined block %x\n", self.block.Hash()) minerlogger.Infoln(self.block) |