aboutsummaryrefslogtreecommitdiffstats
path: root/ethchain/block_chain.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethchain/block_chain.go')
-rw-r--r--ethchain/block_chain.go5
1 files changed, 4 insertions, 1 deletions
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 {