Skip to content

Commit

Permalink
interface: fix only-genesis regtest case
Browse files Browse the repository at this point in the history
  • Loading branch information
SomberNight committed Dec 10, 2018
1 parent 5b9b6a9 commit 0ddccd5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions electrum/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,17 @@ async def sync_until(self, height, next_height=None):
return last, height

async def step(self, height, header=None):
assert height != 0
assert height <= self.tip, (height, self.tip)
assert 0 <= height <= self.tip, (height, self.tip)
if header is None:
header = await self.get_block_header(height, 'catchup')

chain = blockchain.check_header(header) if 'mock' not in header else header['mock']['check'](header)
if chain:
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

can_connect = blockchain.can_connect(header) if 'mock' not in header else header['mock']['connect'](height)
Expand Down

0 comments on commit 0ddccd5

Please sign in to comment.