mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 12:30:07 +00:00
batch fee estimates
This commit is contained in:
parent
ddee03d324
commit
57e66324cb
2 changed files with 11 additions and 8 deletions
|
@ -170,7 +170,8 @@ class Interface(PrintError):
|
|||
sslc.check_hostname = 0
|
||||
try:
|
||||
await self.open_session(sslc, exit_early=False)
|
||||
except (asyncio.CancelledError, ConnectionRefusedError, socket.gaierror, ssl.SSLError, TimeoutError) as e:
|
||||
except (asyncio.CancelledError, ConnectionRefusedError, socket.gaierror,
|
||||
ssl.SSLError, TimeoutError, aiorpcx.socks.SOCKSFailure) as e:
|
||||
self.print_error('disconnecting due to: {}'.format(e))
|
||||
self.exception = e
|
||||
return
|
||||
|
|
|
@ -37,6 +37,7 @@ import concurrent.futures
|
|||
|
||||
import dns
|
||||
import dns.resolver
|
||||
from aiorpcx import TaskGroup
|
||||
|
||||
from . import util
|
||||
from .util import PrintError, print_error, aiosafe, bfh
|
||||
|
@ -343,14 +344,15 @@ class Network(PrintError):
|
|||
session = interface.session
|
||||
from .simple_config import FEE_ETA_TARGETS
|
||||
self.config.requested_fee_estimates()
|
||||
histogram = await session.send_request('mempool.get_fee_histogram')
|
||||
fees = []
|
||||
for i in FEE_ETA_TARGETS:
|
||||
fees.append((i, await session.send_request('blockchain.estimatefee', [i])))
|
||||
self.config.mempool_fees = histogram
|
||||
async with TaskGroup() as group:
|
||||
histogram_task = await group.spawn(session.send_request('mempool.get_fee_histogram'))
|
||||
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.notify('fee_histogram')
|
||||
for i, result in fees:
|
||||
fee = int(result * COIN)
|
||||
for i, task in fee_tasks:
|
||||
fee = int(task.result() * COIN)
|
||||
self.config.update_fee_estimates(i, fee)
|
||||
self.print_error("fee_estimates[%d]" % i, fee)
|
||||
self.notify('fee')
|
||||
|
|
Loading…
Add table
Reference in a new issue