simple address subs instead of batch

This commit is contained in:
Victor Shyba 2019-08-22 16:32:14 -03:00
parent 5e8d169c50
commit 6c3147fcf4
2 changed files with 9 additions and 9 deletions

View file

@ -395,8 +395,12 @@ 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
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):

View file

@ -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: