diff options
Diffstat (limited to 'chain/chain_manager.go')
-rw-r--r-- | chain/chain_manager.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/chain/chain_manager.go b/chain/chain_manager.go index 46e0703c1..df390a4c0 100644 --- a/chain/chain_manager.go +++ b/chain/chain_manager.go @@ -47,7 +47,7 @@ func (bc *ChainManager) NewBlock(coinbase []byte) *Block { hash := ZeroHash256 if bc.CurrentBlock != nil { - root = bc.CurrentBlock.state.Trie.Root + root = bc.CurrentBlock.Root() hash = bc.LastBlockHash } @@ -206,7 +206,7 @@ func (bc *ChainManager) add(block *Block) { 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]) + //chainlogger.Infof("Imported block #%d (%x...)\n", block.Number, block.Hash()[0:4]) } func (self *ChainManager) CalcTotalDiff(block *Block) (*big.Int, error) { @@ -328,15 +328,22 @@ func (self *ChainManager) InsertChain(chain *BlockChain) { for e := chain.Front(); e != nil; e = e.Next() { link := e.Value.(*link) - self.SetTotalDifficulty(link.td) self.add(link.block) + self.SetTotalDifficulty(link.td) self.Ethereum.EventMux().Post(NewBlockEvent{link.block}) self.Ethereum.EventMux().Post(link.messages) } + + b, e := chain.Front(), chain.Back() + if b != nil && e != nil { + front, back := b.Value.(*link).block, e.Value.(*link).block + chainlogger.Infof("Imported %d blocks. #%v (%x) / %#v (%x)", chain.Len(), front.Number, front.Hash()[0:4], back.Number, back.Hash()[0:4]) + } } func (self *ChainManager) TestChain(chain *BlockChain) (td *big.Int, err error) { self.workingChain = chain + defer func() { self.workingChain = nil }() for e := chain.Front(); e != nil; e = e.Next() { var ( |