batch fee estimates
This commit is contained in:
@@ -170,7 +170,8 @@ class Interface(PrintError):
|
|||||||
sslc.check_hostname = 0
|
sslc.check_hostname = 0
|
||||||
try:
|
try:
|
||||||
await self.open_session(sslc, exit_early=False)
|
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.print_error('disconnecting due to: {}'.format(e))
|
||||||
self.exception = e
|
self.exception = e
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import concurrent.futures
|
|||||||
|
|
||||||
import dns
|
import dns
|
||||||
import dns.resolver
|
import dns.resolver
|
||||||
|
from aiorpcx import TaskGroup
|
||||||
|
|
||||||
from . import util
|
from . import util
|
||||||
from .util import PrintError, print_error, aiosafe, bfh
|
from .util import PrintError, print_error, aiosafe, bfh
|
||||||
@@ -343,14 +344,15 @@ class Network(PrintError):
|
|||||||
session = interface.session
|
session = interface.session
|
||||||
from .simple_config import FEE_ETA_TARGETS
|
from .simple_config import FEE_ETA_TARGETS
|
||||||
self.config.requested_fee_estimates()
|
self.config.requested_fee_estimates()
|
||||||
histogram = await session.send_request('mempool.get_fee_histogram')
|
async with TaskGroup() as group:
|
||||||
fees = []
|
histogram_task = await group.spawn(session.send_request('mempool.get_fee_histogram'))
|
||||||
for i in FEE_ETA_TARGETS:
|
fee_tasks = []
|
||||||
fees.append((i, await session.send_request('blockchain.estimatefee', [i])))
|
for i in FEE_ETA_TARGETS:
|
||||||
self.config.mempool_fees = histogram
|
fee_tasks.append((i, await group.spawn(session.send_request('blockchain.estimatefee', [i]))))
|
||||||
|
self.config.mempool_fees = histogram_task.result()
|
||||||
self.notify('fee_histogram')
|
self.notify('fee_histogram')
|
||||||
for i, result in fees:
|
for i, task in fee_tasks:
|
||||||
fee = int(result * COIN)
|
fee = int(task.result() * COIN)
|
||||||
self.config.update_fee_estimates(i, fee)
|
self.config.update_fee_estimates(i, fee)
|
||||||
self.print_error("fee_estimates[%d]" % i, fee)
|
self.print_error("fee_estimates[%d]" % i, fee)
|
||||||
self.notify('fee')
|
self.notify('fee')
|
||||||
|
|||||||
Reference in New Issue
Block a user