diff options
author | Maran <maran.hidskes@gmail.com> | 2014-03-24 17:24:06 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-03-24 17:24:06 +0800 |
commit | 274d5cc91c45349ec8d7a1f5a20ef29896b38b2e (patch) | |
tree | 6524987835bcfebd788fd3e89e3a42603cd9f056 /ethchain | |
parent | b52b1fca89fd56549ecc0f086d96a39d6009e568 (diff) | |
download | dexon-274d5cc91c45349ec8d7a1f5a20ef29896b38b2e.tar.gz dexon-274d5cc91c45349ec8d7a1f5a20ef29896b38b2e.tar.zst dexon-274d5cc91c45349ec8d7a1f5a20ef29896b38b2e.zip |
FindCanonicalChain returns true or false when we are on the Canonical chain or not
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/block_chain.go | 5 |
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 { |