forked from LBRYCommunity/lbry-sdk
simple address subs instead of batch
This commit is contained in:
parent
5e8d169c50
commit
6c3147fcf4
2 changed files with 9 additions and 9 deletions
|
@ -395,8 +395,12 @@ class BaseLedger(metaclass=LedgerRegistry):
|
||||||
|
|
||||||
async def subscribe_addresses(self, address_manager: baseaccount.AddressManager, addresses: List[str]):
|
async def subscribe_addresses(self, address_manager: baseaccount.AddressManager, addresses: List[str]):
|
||||||
if self.network.is_connected and addresses:
|
if self.network.is_connected and addresses:
|
||||||
async for address, remote_status in self.network.subscribe_address(*addresses):
|
await asyncio.wait([
|
||||||
# subscribe isnt a retriable call as it happens right after a connection is made
|
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))
|
self._update_tasks.add(self.update_history(address, remote_status, address_manager))
|
||||||
|
|
||||||
def process_status_update(self, update):
|
def process_status_update(self, update):
|
||||||
|
|
|
@ -242,12 +242,8 @@ class BaseNetwork:
|
||||||
def subscribe_headers(self):
|
def subscribe_headers(self):
|
||||||
return self.rpc('blockchain.headers.subscribe', [True], session=self.client)
|
return self.rpc('blockchain.headers.subscribe', [True], session=self.client)
|
||||||
|
|
||||||
async def subscribe_address(self, *addresses):
|
def subscribe_address(self, address):
|
||||||
async with self.client.send_batch() as batch:
|
return self.rpc('blockchain.address.subscribe', [address], session=self.client)
|
||||||
for address in addresses:
|
|
||||||
batch.add_request('blockchain.address.subscribe', [address])
|
|
||||||
for address, status in zip(addresses, batch.results):
|
|
||||||
yield address, status
|
|
||||||
|
|
||||||
|
|
||||||
class SessionPool:
|
class SessionPool:
|
||||||
|
|
Loading…
Reference in a new issue