From 6c3147fcf45d159558a303a40b12cf7b813f9d78 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 22 Aug 2019 16:32:14 -0300 Subject: [PATCH] simple address subs instead of batch --- torba/torba/client/baseledger.py | 10 +++++++--- torba/torba/client/basenetwork.py | 8 ++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/torba/torba/client/baseledger.py b/torba/torba/client/baseledger.py index 88959fb38..d915b1308 100644 --- a/torba/torba/client/baseledger.py +++ b/torba/torba/client/baseledger.py @@ -395,9 +395,13 @@ class BaseLedger(metaclass=LedgerRegistry): async def subscribe_addresses(self, address_manager: baseaccount.AddressManager, addresses: List[str]): if self.network.is_connected and addresses: - async for address, remote_status in self.network.subscribe_address(*addresses): - # subscribe isnt a retriable call as it happens right after a connection is made - self._update_tasks.add(self.update_history(address, remote_status, address_manager)) + await asyncio.wait([ + self.subscribe_address(address_manager, address) for address in addresses + ]) + + async def subscribe_address(self, address_manager: baseaccount.AddressManager, address: str): + remote_status = await self.network.subscribe_address(address) + self._update_tasks.add(self.update_history(address, remote_status, address_manager)) def process_status_update(self, update): address, remote_status = update diff --git a/torba/torba/client/basenetwork.py b/torba/torba/client/basenetwork.py index 4ff0d63e0..7a0a5053d 100644 --- a/torba/torba/client/basenetwork.py +++ b/torba/torba/client/basenetwork.py @@ -242,12 +242,8 @@ class BaseNetwork: def subscribe_headers(self): return self.rpc('blockchain.headers.subscribe', [True], session=self.client) - async def subscribe_address(self, *addresses): - async with self.client.send_batch() as batch: - for address in addresses: - batch.add_request('blockchain.address.subscribe', [address]) - for address, status in zip(addresses, batch.results): - yield address, status + def subscribe_address(self, address): + return self.rpc('blockchain.address.subscribe', [address], session=self.client) class SessionPool: