From 5872bd4722eb7058781b1e4767ea619684aa3d16 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Thu, 3 Aug 2017 14:25:50 +0200 Subject: [PATCH] force new headers download if file is corrupted --- lib/blockchain.py | 2 +- lib/network.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/blockchain.py b/lib/blockchain.py index a02799b7..ba9d7d2b 100644 --- a/lib/blockchain.py +++ b/lib/blockchain.py @@ -258,7 +258,7 @@ class Blockchain(util.PrintError): return deserialize_header(h, height) def get_hash(self, height): - return bitcoin.GENESIS if height == 0 else hash_header(self.read_header(height)) + return hash_header(self.read_header(height)) def BIP9(self, height, flag): v = self.read_header(height)['version'] diff --git a/lib/network.py b/lib/network.py index e6c32beb..1a45c313 100644 --- a/lib/network.py +++ b/lib/network.py @@ -946,10 +946,11 @@ class Network(util.DaemonThread): self.process_responses(interface) def init_headers_file(self): - filename = self.blockchains[0].path() - if os.path.exists(filename): + b = self.blockchains[0] + if b.get_hash(0) == bitcoin.GENESIS: self.downloading_headers = False return + filename = b.path() def download_thread(): try: import urllib, socket