diff options
author | Maran <maran.hidskes@gmail.com> | 2014-03-31 18:54:37 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-03-31 18:54:37 +0800 |
commit | 5f49a659c36dbfb8c330ddc3d4565c19a9a936b5 (patch) | |
tree | 61e4c356238474e6c7e9965755e4a37a95a19f18 /ethchain/block_chain.go | |
parent | 6253d109389d49e47772597de24cd11874b91338 (diff) | |
download | go-tangerine-5f49a659c36dbfb8c330ddc3d4565c19a9a936b5.tar go-tangerine-5f49a659c36dbfb8c330ddc3d4565c19a9a936b5.tar.gz go-tangerine-5f49a659c36dbfb8c330ddc3d4565c19a9a936b5.tar.bz2 go-tangerine-5f49a659c36dbfb8c330ddc3d4565c19a9a936b5.tar.lz go-tangerine-5f49a659c36dbfb8c330ddc3d4565c19a9a936b5.tar.xz go-tangerine-5f49a659c36dbfb8c330ddc3d4565c19a9a936b5.tar.zst go-tangerine-5f49a659c36dbfb8c330ddc3d4565c19a9a936b5.zip |
More blockchain testing
Diffstat (limited to 'ethchain/block_chain.go')
-rw-r--r-- | ethchain/block_chain.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go index 0e3601a4b..8c03eec38 100644 --- a/ethchain/block_chain.go +++ b/ethchain/block_chain.go @@ -126,6 +126,7 @@ func (bc *BlockChain) FindCanonicalChain(blocks []*Block, commonBlockHash []byte log.Println("[CHAIN] We have found the common parent block, breaking") break } + log.Println("Checking incoming blocks:") chainDifficulty.Add(chainDifficulty, bc.CalculateBlockTD(block)) } @@ -139,13 +140,20 @@ func (bc *BlockChain) FindCanonicalChain(blocks []*Block, commonBlockHash []byte log.Println("[CHAIN] We have found the common parent block, breaking") break } - log.Println("CHECKING BLOGK:", i) + anOtherBlock := bc.GetBlock(block.PrevHash) + if anOtherBlock == nil { + // We do not want to count the genesis block for difficulty since that's not being sent + log.Println("[CHAIN] At genesis block, breaking") + break + } + log.Printf("CHECKING OUR OWN BLOCKS: %x", block.Hash()) + log.Printf("%x", bc.GenesisBlock().Hash()) curChainDifficulty.Add(curChainDifficulty, bc.CalculateBlockTD(block)) } log.Println("[CHAIN] Current chain difficulty:", curChainDifficulty) if chainDifficulty.Cmp(curChainDifficulty) == 1 { - log.Println("[CHAIN] The incoming Chain beat our asses, resetting") + log.Printf("[CHAIN] The incoming Chain beat our asses, resetting to block: %x", commonBlockHash) bc.ResetTillBlockHash(commonBlockHash) return false } else { @@ -165,6 +173,7 @@ func (bc *BlockChain) ResetTillBlockHash(hash []byte) error { // END TODO bc.Ethereum.StateManager().PrepareDefault(returnTo) + err := ethutil.Config.Db.Delete(lastBlock.Hash()) if err != nil { return err |