Skip to content

Commit

Permalink
Bug fix. repeated initialization of 'additional keys'. (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
AustEcon committed Feb 21, 2020
1 parent a73d492 commit 20509a4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions electrumsv/network.py
Expand Up @@ -1226,11 +1226,12 @@ async def _monitor_txs(self, account):
async def _monitor_active_keys(self, account) -> None:
'''Raises: RPCError, TaskTimeout'''
all_keys = set(account.existing_active_keys())
session = await self._main_session()
monitored_keyinstance_ids = set([v[0] for v in session._keyinstance_map.values()])

This comment has been minimized.

Copy link
@kyuupichan

kyuupichan Feb 22, 2020

Collaborator

This is inefficient - you are creating an array and then creating a set from it. You should just create the set directly from the generator.

additional_keys = all_keys - monitored_keyinstance_ids

while True:
session = await self._main_session()
monitored_keyinstance_ids = set([v[0] for k, v in session._keyinstance_map.items()])
additional_keys = all_keys - monitored_keyinstance_ids

session.logger.info(f'subscribing to {len(additional_keys):,d} new keys for {account}')
# Do in reverse to require fewer account re-sync loops
pairs = [ (k, script_type, scripthash_hex(script)) for k in additional_keys
Expand Down

0 comments on commit 20509a4

Please sign in to comment.