|
|
@ -66,8 +66,7 @@ class SimpleConfig(Logger): |
|
|
|
self.lock = threading.RLock() |
|
|
|
|
|
|
|
self.mempool_fees = None # type: Optional[Sequence[Tuple[Union[float, int], int]]] |
|
|
|
self.fee_estimates = {} |
|
|
|
self.fee_estimates_last_updated = {} |
|
|
|
self.fee_estimates = {} # type: Dict[int, int] |
|
|
|
self.last_time_fee_estimates_requested = 0 # zero ensures immediate fees |
|
|
|
|
|
|
|
# The following two functions are there for dependency injection when |
|
|
@ -517,10 +516,10 @@ class SimpleConfig(Logger): |
|
|
|
def static_fee(self, i): |
|
|
|
return FEERATE_STATIC_VALUES[i] |
|
|
|
|
|
|
|
def static_fee_index(self, value) -> int: |
|
|
|
if value is None: |
|
|
|
def static_fee_index(self, fee_per_kb: Optional[int]) -> int: |
|
|
|
if fee_per_kb is None: |
|
|
|
raise TypeError('static fee cannot be None') |
|
|
|
dist = list(map(lambda x: abs(x - value), FEERATE_STATIC_VALUES)) |
|
|
|
dist = list(map(lambda x: abs(x - fee_per_kb), FEERATE_STATIC_VALUES)) |
|
|
|
return min(range(len(dist)), key=dist.__getitem__) |
|
|
|
|
|
|
|
def has_fee_etas(self): |
|
|
@ -611,9 +610,10 @@ class SimpleConfig(Logger): |
|
|
|
fee_per_byte = quantize_feerate(fee_per_byte) |
|
|
|
return round(fee_per_byte * size) |
|
|
|
|
|
|
|
def update_fee_estimates(self, key, value): |
|
|
|
self.fee_estimates[key] = value |
|
|
|
self.fee_estimates_last_updated[key] = time.time() |
|
|
|
def update_fee_estimates(self, nblock_target: int, fee_per_kb: int): |
|
|
|
assert isinstance(nblock_target, int), f"expected int, got {nblock_target!r}" |
|
|
|
assert isinstance(fee_per_kb, int), f"expected int, got {fee_per_kb!r}" |
|
|
|
self.fee_estimates[nblock_target] = fee_per_kb |
|
|
|
|
|
|
|
def is_fee_estimates_update_required(self): |
|
|
|
"""Checks time since last requested and updated fee estimates. |
|
|
|