From ff3a891afe4e530dbd67249375c2cdf63d361126 Mon Sep 17 00:00:00 2001 From: Gustav Simonsson Date: Tue, 5 May 2015 03:48:55 +0200 Subject: [PATCH] Remove old CalcTotalDiff function, improve code comments --- core/chain_manager.go | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/core/chain_manager.go b/core/chain_manager.go index 71da08f5e2..9f3af21245 100644 --- a/core/chain_manager.go +++ b/core/chain_manager.go @@ -74,10 +74,10 @@ type ChainManager struct { processor types.BlockProcessor eventMux *event.TypeMux genesisBlock *types.Block - // Last known total difficulty - mu sync.RWMutex - tsmu sync.RWMutex + mu sync.RWMutex + tsmu sync.RWMutex + // Last known total difficulty td *big.Int currentBlock *types.Block lastBlockHash common.Hash @@ -458,26 +458,6 @@ func (bc *ChainManager) setTotalDifficulty(td *big.Int) { bc.td = td } -func (self *ChainManager) CalcTotalDiff(block *types.Block) (*big.Int, error) { - parent := self.GetBlock(block.Header().ParentHash) - if parent == nil { - return nil, fmt.Errorf("Unable to calculate total diff without known parent %x", block.Header().ParentHash) - } - - parentTd := parent.Td - - uncleDiff := new(big.Int) - for _, uncle := range block.Uncles() { - uncleDiff = uncleDiff.Add(uncleDiff, uncle.Difficulty) - } - - td := new(big.Int) - td = td.Add(parentTd, uncleDiff) - td = td.Add(td, block.Header().Difficulty) - - return td, nil -} - func (bc *ChainManager) Stop() { close(bc.quit) @@ -534,7 +514,7 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) { } block.Td = new(big.Int) - // Do not penelise on future block. We'll need a block queue eventually that will queue + // Do not penalize on future block. We'll need a block queue eventually that will queue // future block for future use if err == BlockFutureErr { block.SetQueued(true)