From 274d5cc91c45349ec8d7a1f5a20ef29896b38b2e Mon Sep 17 00:00:00 2001 From: Maran Date: Mon, 24 Mar 2014 10:24:06 +0100 Subject: FindCanonicalChain returns true or false when we are on the Canonical chain or not --- ethchain/block_chain.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ethchain/block_chain.go') diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go index 6eea14652..f25f0ca5a 100644 --- a/ethchain/block_chain.go +++ b/ethchain/block_chain.go @@ -103,7 +103,8 @@ func (bc *BlockChain) CalculateBlockTD(block *Block) *big.Int { } // Is tasked by finding the CanonicalChain and resetting the chain if we are not the Conical one -func (bc *BlockChain) FindCanonicalChain(msg *ethwire.Msg, commonBlockHash []byte) { +// Return true if we are the using the canonical chain false if not +func (bc *BlockChain) FindCanonicalChain(msg *ethwire.Msg, commonBlockHash []byte) bool { // 1. Calculate TD of the current chain // 2. Calculate TD of the new chain // Reset state to the correct one @@ -138,8 +139,10 @@ func (bc *BlockChain) FindCanonicalChain(msg *ethwire.Msg, commonBlockHash []byt if chainDifficulty.Cmp(curChainDifficulty) == 1 { log.Println("[BCHAIN] The incoming Chain beat our asses, resetting") bc.ResetTillBlockHash(commonBlockHash) + return false } else { log.Println("[BCHAIN] Our chain showed the incoming chain who is boss. Ignoring.") + return true } } func (bc *BlockChain) ResetTillBlockHash(hash []byte) error { -- cgit