Browse Source

fee estimation: split eta_to_fee into two methods

3.2.x
SomberNight 7 years ago
parent
commit
629b9cb3b5
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 20
      electrum/simple_config.py

20
electrum/simple_config.py

@ -4,7 +4,7 @@ import time
import os
import stat
from decimal import Decimal
from typing import Union
from typing import Union, Optional
from numbers import Real
from copy import deepcopy
@ -296,19 +296,27 @@ class SimpleConfig(PrintError):
return fee
return get_fee_within_limits
@impose_hard_limits_on_fee
def eta_to_fee(self, slider_pos) -> Union[int, None]:
def eta_to_fee(self, slider_pos) -> Optional[int]:
"""Returns fee in sat/kbyte."""
slider_pos = max(slider_pos, 0)
slider_pos = min(slider_pos, len(FEE_ETA_TARGETS))
if slider_pos < len(FEE_ETA_TARGETS):
target_blocks = FEE_ETA_TARGETS[slider_pos]
fee = self.fee_estimates.get(target_blocks)
num_blocks = FEE_ETA_TARGETS[slider_pos]
fee = self.eta_target_to_fee(num_blocks)
else:
fee = self.eta_target_to_fee(1)
return fee
@impose_hard_limits_on_fee
def eta_target_to_fee(self, num_blocks: int) -> Optional[int]:
"""Returns fee in sat/kbyte."""
if num_blocks == 1:
fee = self.fee_estimates.get(2)
if fee is not None:
fee += fee/2
fee += fee / 2
fee = int(fee)
else:
fee = self.fee_estimates.get(num_blocks)
return fee
def fee_to_depth(self, target_fee: Real) -> int:

Loading…
Cancel
Save