create_task instead of ensure_future

This commit is contained in:
Jack Robison 2020-03-25 17:48:05 -04:00
parent 11525c7d0d
commit bc4075e2ed
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -497,14 +497,15 @@ class Ledger(metaclass=LedgerRegistry):
if not we_need:
return True
cache_tasks: List[asyncio.Future[Transaction]] = []
cache_tasks: List[asyncio.Task[Transaction]] = []
synced_history = StringIO()
loop = asyncio.get_running_loop()
for i, (txid, remote_height) in enumerate(remote_history):
if i < len(local_history) and local_history[i] == (txid, remote_height) and not cache_tasks:
synced_history.write(f'{txid}:{remote_height}:')
else:
check_local = (txid, remote_height) not in we_need
cache_tasks.append(asyncio.ensure_future(
cache_tasks.append(loop.create_task(
self.cache_transaction(txid, remote_height, check_local=check_local)
))