From de010089926f152964519b190b47f0f6816d7aa7 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Wed, 13 Dec 2017 13:43:51 +0100 Subject: [PATCH] blockchain: do not load forks that cannot connect to the main headers file --- lib/blockchain.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/blockchain.py b/lib/blockchain.py index 12a6e79c9..e454e079a 100644 --- a/lib/blockchain.py +++ b/lib/blockchain.py @@ -71,7 +71,11 @@ def read_blockchains(config): checkpoint = int(filename.split('_')[2]) parent_id = int(filename.split('_')[1]) b = Blockchain(config, checkpoint, parent_id) - blockchains[b.checkpoint] = b + h = b.read_header(b.checkpoint) + if b.parent().can_connect(h, check_height=False): + blockchains[b.checkpoint] = b + else: + util.print_error("cannot connect", filename) return blockchains def check_header(header): @@ -318,7 +322,6 @@ class Blockchain(util.PrintError): except: return False if prev_hash != header.get('prev_block_hash'): - self.print_error("bad hash", height, prev_hash, header.get('prev_block_hash')) return False target = self.get_target(height // 2016 - 1) try: