From 9925916851c00323336e213fc18c83da5fceee94 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 5 Dec 2014 16:26:39 +0100 Subject: [PATCH] upped proto version and modified block pool --- block_pool.go | 2 +- cmd/ethereum/main.go | 2 +- cmd/mist/gui.go | 4 ---- cmd/mist/main.go | 2 +- core/chain_manager.go | 24 +++++++++++++++--------- miner/miner.go | 1 - 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/block_pool.go b/block_pool.go index 02eb65d47..803927f21 100644 --- a/block_pool.go +++ b/block_pool.go @@ -154,7 +154,7 @@ func (self *BlockPool) addBlock(b *types.Block, peer *Peer, newBlock bool) { fmt.Println("1.", !self.eth.ChainManager().HasBlock(b.PrevHash), ethutil.Bytes2Hex(b.Hash()[0:4]), ethutil.Bytes2Hex(b.PrevHash[0:4])) fmt.Println("2.", self.pool[string(b.PrevHash)] == nil) fmt.Println("3.", !self.fetchingHashes) - if !self.eth.ChainManager().HasBlock(b.PrevHash) && self.pool[string(b.PrevHash)] == nil && !self.fetchingHashes { + if !self.eth.ChainManager().HasBlock(b.PrevHash) /*&& self.pool[string(b.PrevHash)] == nil*/ && !self.fetchingHashes { poollogger.Infof("Unknown chain, requesting (%x...)\n", b.PrevHash[0:4]) peer.QueueMessage(wire.NewMessage(wire.MsgGetBlockHashesTy, []interface{}{b.Hash(), uint32(256)})) } diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index 14921bf10..43551fb3a 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -30,7 +30,7 @@ import ( const ( ClientIdentifier = "Ethereum(G)" - Version = "0.7.8" + Version = "0.7.9" ) var clilogger = logger.NewLogger("CLI") diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go index 6a28b48f9..0b03cdc1b 100644 --- a/cmd/mist/gui.go +++ b/cmd/mist/gui.go @@ -389,7 +389,6 @@ func (gui *Gui) update() { gui.loadAddressBook() gui.loadMergedMiningOptions() gui.setPeerInfo() - //gui.readPreviousTransactions() }() for _, plugin := range gui.plugins { @@ -417,9 +416,6 @@ func (gui *Gui) update() { core.TxPostEvent{}, ) - // nameReg := gui.pipe.World().Config().Get("NameReg") - // mux.Subscribe("object:"+string(nameReg.Address()), objectChan) - go func() { defer events.Unsubscribe() for { diff --git a/cmd/mist/main.go b/cmd/mist/main.go index 5503097f2..14336b4e8 100644 --- a/cmd/mist/main.go +++ b/cmd/mist/main.go @@ -31,7 +31,7 @@ import ( const ( ClientIdentifier = "Mist" - Version = "0.7.8" + Version = "0.7.9" ) var ethereum *eth.Ethereum diff --git a/core/chain_manager.go b/core/chain_manager.go index 7d4aeaab6..150139def 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -125,7 +125,8 @@ func (bc *ChainManager) Reset() { bc.genesisBlock.Trie().Sync() // Prepare the genesis block - bc.add(bc.genesisBlock) + bc.write(bc.genesisBlock) + bc.insert(bc.genesisBlock) bc.CurrentBlock = bc.genesisBlock bc.SetTotalDifficulty(ethutil.Big("0")) @@ -134,18 +135,18 @@ func (bc *ChainManager) Reset() { bc.TD = ethutil.BigD(ethutil.Config.Db.LastKnownTD()) } -// Add a block to the chain and record addition information -func (bc *ChainManager) add(block *types.Block) { - bc.writeBlockInfo(block) - +func (bc *ChainManager) insert(block *types.Block) { + encodedBlock := block.RlpEncode() + ethutil.Config.Db.Put([]byte("LastBlock"), encodedBlock) bc.CurrentBlock = block bc.LastBlockHash = block.Hash() +} + +func (bc *ChainManager) write(block *types.Block) { + bc.writeBlockInfo(block) encodedBlock := block.RlpEncode() ethutil.Config.Db.Put(block.Hash(), encodedBlock) - ethutil.Config.Db.Put([]byte("LastBlock"), encodedBlock) - - //chainlogger.Infof("Imported block #%d (%x...)\n", block.Number, block.Hash()[0:4]) } // Accessors @@ -266,9 +267,14 @@ func (self *ChainManager) InsertChain(chain types.Blocks) error { return err } - self.add(block) + self.write(block) if td.Cmp(self.TD) > 0 { + if block.Number.Cmp(new(big.Int).Add(self.CurrentBlock.Number, ethutil.Big1)) < 0 { + chainlogger.Infof("Split detected. New head #%v (%x), was #%v (%x)\n", block.Number, block.Hash()[:4], self.CurrentBlock.Number, self.CurrentBlock.Hash()[:4]) + } + self.SetTotalDifficulty(td) + self.insert(block) } self.eventMux.Post(NewBlockEvent{block}) diff --git a/miner/miner.go b/miner/miner.go index c350eb1a8..4f677cbef 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -167,7 +167,6 @@ out: } func (self *Miner) reset() { - println("reset") close(self.powQuitCh) self.powQuitCh = make(chan struct{}) }