Browse Source

fix bug if headers file is empty

master
ThomasV 9 years ago
parent
commit
feb0f483f5
  1. 2
      lib/blockchain.py
  2. 10
      lib/network.py

2
lib/blockchain.py

@ -286,6 +286,8 @@ class Blockchain(util.PrintError):
height = header['block_height'] height = header['block_height']
if self.height() != height - 1: if self.height() != height - 1:
return False return False
if height == 0:
return hash_header(header) == bitcoin.GENESIS
previous_header = self.read_header(height -1) previous_header = self.read_header(height -1)
if not previous_header: if not previous_header:
return False return False

10
lib/network.py

@ -990,11 +990,19 @@ class Network(util.DaemonThread):
self.notify('interfaces') self.notify('interfaces')
self.switch_lagging_interface() self.switch_lagging_interface()
return return
tip = max([x.height() for x in self.blockchains.values()])
if tip >=0:
interface.mode = 'backward' interface.mode = 'backward'
interface.bad = height interface.bad = height
interface.bad_header = header interface.bad_header = header
tip = max([x.height() for x in self.blockchains.values()])
self.request_header(interface, tip) self.request_header(interface, tip)
else:
chain = self.blockchains[0]
if chain.catch_up is None:
chain.catch_up = interface
interface.mode = 'catch_up'
interface.blockchain = chain
self.request_header(interface, 0)
def blockchain(self): def blockchain(self):
if self.interface and self.interface.blockchain is not None: if self.interface and self.interface.blockchain is not None:

Loading…
Cancel
Save