Browse Source

interface: fix only-genesis regtest case

3.3.3.1
SomberNight 6 years ago
parent
commit
0ddccd56c7
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 7
      electrum/interface.py

7
electrum/interface.py

@ -438,14 +438,17 @@ class Interface(PrintError):
return last, height return last, height
async def step(self, height, header=None): async def step(self, height, header=None):
assert height != 0 assert 0 <= height <= self.tip, (height, self.tip)
assert height <= self.tip, (height, self.tip)
if header is None: if header is None:
header = await self.get_block_header(height, 'catchup') header = await self.get_block_header(height, 'catchup')
chain = blockchain.check_header(header) if 'mock' not in header else header['mock']['check'](header) chain = blockchain.check_header(header) if 'mock' not in header else header['mock']['check'](header)
if chain: if chain:
self.blockchain = chain if isinstance(chain, Blockchain) else self.blockchain self.blockchain = chain if isinstance(chain, Blockchain) else self.blockchain
# note: there is an edge case here that is not handled.
# we might know the blockhash (enough for check_header) but
# not have the header itself. e.g. regtest chain with only genesis.
# this situation resolves itself on the next block
return 'catchup', height+1 return 'catchup', height+1
can_connect = blockchain.can_connect(header) if 'mock' not in header else header['mock']['connect'](height) can_connect = blockchain.can_connect(header) if 'mock' not in header else header['mock']['connect'](height)

Loading…
Cancel
Save