From 3f69595fbd176771b1c68ef2dd42351a384bb5d6 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Mon, 13 Aug 2018 14:44:35 +0900 Subject: [PATCH] Improve estimatefee API --- electrumx/server/daemon.py | 14 +++++++++----- electrumx/server/session.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/electrumx/server/daemon.py b/electrumx/server/daemon.py index c733ef9..e642aa9 100644 --- a/electrumx/server/daemon.py +++ b/electrumx/server/daemon.py @@ -216,12 +216,16 @@ class Daemon(object): '''Update our record of the daemon's mempool hashes.''' return await self._send_single('getrawmempool') - async def estimatefee(self, params): - '''Return the fee estimate for the given parameters.''' + async def estimatefee(self, block_count): + '''Return the fee estimate for the block count. Units are whole + currency units per KB, e.g. 0.00000995, or -1 if no estimate + is available. + ''' + args = (block_count, ) if await self._is_rpc_available('estimatesmartfee'): - estimate = await self._send_single('estimatesmartfee', params) + estimate = await self._send_single('estimatesmartfee', args) return estimate.get('feerate', -1) - return await self._send_single('estimatefee', params) + return await self._send_single('estimatefee', args) async def getnetworkinfo(self): '''Return the result of the 'getnetworkinfo' RPC call.''' @@ -280,7 +284,7 @@ class FakeEstimateFeeDaemon(Daemon): '''Daemon that simulates estimatefee and relayfee RPC calls. Coin that wants to use this daemon must define ESTIMATE_FEE & RELAY_FEE''' - async def estimatefee(self, params): + async def estimatefee(self, block_count): '''Return the fee estimate for the given parameters.''' return self.coin.ESTIMATE_FEE diff --git a/electrumx/server/session.py b/electrumx/server/session.py index c45fb1d..c379f45 100644 --- a/electrumx/server/session.py +++ b/electrumx/server/session.py @@ -1088,7 +1088,7 @@ class ElectrumX(SessionBase): number: the number of blocks ''' number = non_negative_integer(number) - return await self.daemon_request('estimatefee', [number]) + return await self.daemon_request('estimatefee', number) async def ping(self): '''Serves as a connection keep-alive mechanism and for the client to