From f316c999f9b01792eb74aaa3f32299db7ef7a2d5 Mon Sep 17 00:00:00 2001 From: Damon C Date: Wed, 7 Aug 2019 18:22:51 -0700 Subject: [PATCH] handle previously synced chains --- nucypher/blockchain/eth/interfaces.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nucypher/blockchain/eth/interfaces.py b/nucypher/blockchain/eth/interfaces.py index 8ebd764df..d933c4295 100644 --- a/nucypher/blockchain/eth/interfaces.py +++ b/nucypher/blockchain/eth/interfaces.py @@ -269,7 +269,13 @@ class BlockchainInterface: peer_count = len(self.client.peers) emitter.echo(f"Found {'an' if peer_count == 1 else peer_count} Ethereum peer{('s' if peer_count>1 else '')}.") - initial_state = next(sync_state) or {} + try: + emitter.echo("Beginning sync...") + initial_state = next(sync_state) + except StopIteration: # will occur if no syncing needs to happen + emitter.echo("Local blockchain data is already synced.") + return True + prior_state = initial_state total_blocks_to_sync = int(initial_state.get('highestBlock', 0)) - int(initial_state.get('currentBlock', 0)) with click.progressbar(