electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 6452582a17736921c5021436719ab81d0416cbae
parent e7fa42ce3ecef126d5e34fec206ec85173122d1b
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed, 12 Sep 2018 21:18:08 +0200

network: batch requests in request_server_info

Diffstat:
Melectrum/network.py | 35++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/electrum/network.py b/electrum/network.py @@ -317,14 +317,30 @@ class Network(PrintError): async def request_server_info(self, interface): await interface.ready session = interface.session - self.banner = await session.send_request('server.banner') - self.notify('banner') - self.donation_address = await session.send_request('server.donation_address') - self.irc_servers = parse_servers(await session.send_request('server.peers.subscribe')) - self.notify('servers') - await self.request_fee_estimates(interface) - relayfee = await session.send_request('blockchain.relayfee') - self.relay_fee = int(relayfee * COIN) if relayfee is not None else None + + async def get_banner(): + self.banner = await session.send_request('server.banner') + self.notify('banner') + async def get_donation_address(): + self.donation_address = await session.send_request('server.donation_address') + async def get_server_peers(): + self.irc_servers = parse_servers(await session.send_request('server.peers.subscribe')) + self.notify('servers') + async def get_relay_fee(): + relayfee = await session.send_request('blockchain.relayfee') + if relayfee is None: + self.relay_fee = None + else: + relayfee = int(relayfee * COIN) + self.relay_fee = max(0, relayfee) + + # note: we could use interface.group if we wanted exceptions to kill the interface + async with TaskGroup() as group: + await group.spawn(get_banner) + await group.spawn(get_donation_address) + await group.spawn(get_server_peers) + await group.spawn(get_relay_fee) + await group.spawn(self.request_fee_estimates(interface)) async def request_fee_estimates(self, interface): session = interface.session @@ -335,7 +351,8 @@ class Network(PrintError): fee_tasks = [] for i in FEE_ETA_TARGETS: fee_tasks.append((i, await group.spawn(session.send_request('blockchain.estimatefee', [i])))) - self.config.mempool_fees = histogram_task.result() + self.config.mempool_fees = histogram = histogram_task.result() + self.print_error('fee_histogram', histogram) self.notify('fee_histogram') for i, task in fee_tasks: fee = int(task.result() * COIN)