mirror of
https://github.com/bitromortac/lndmanage.git
synced 2026-08-13 12:33:37 +02:00
liquidityhints: synchronize mc data conditionally
This commit is contained in:
parent
9d758fc05e
commit
e6348244c7
2 changed files with 7 additions and 4 deletions
|
|
@ -216,6 +216,7 @@ class LiquidityHintMgr:
|
|||
# badness hints have an exponential decay time of BADNESS_DECAY_SEC updated
|
||||
# every BADNESS_DECAY_ADJUSTMENT_SEC
|
||||
self._badness_timestamps: Dict[NodeID, float] = defaultdict(float)
|
||||
self.mc_sync_timestamp: int = 0
|
||||
|
||||
@property
|
||||
def now(self):
|
||||
|
|
@ -382,6 +383,7 @@ class LiquidityHintMgr:
|
|||
return string
|
||||
|
||||
def extend_with_mission_control(self, mc_pairs):
|
||||
logger.info("> Syncing mission control data.")
|
||||
for pair in mc_pairs:
|
||||
node_from = pair.node_from.hex()
|
||||
node_to = pair.node_to.hex()
|
||||
|
|
@ -397,3 +399,4 @@ class LiquidityHintMgr:
|
|||
node_from, node_to, pair.history.fail_amt_msat,
|
||||
pair.history.fail_time,
|
||||
)
|
||||
self.mc_sync_timestamp = int(time.time())
|
||||
|
|
@ -90,11 +90,11 @@ class Network:
|
|||
except Exception as e:
|
||||
logger.exception(e)
|
||||
|
||||
# TODO: don't load if we loaded some time ago
|
||||
# we extend our information with data from mission control
|
||||
mc_pairs = self.node.query_mc()
|
||||
self.liquidity_hints.extend_with_mission_control(mc_pairs)
|
||||
self.save_liquidty_hints()
|
||||
if self.liquidity_hints.mc_sync_timestamp < time.time() - settings.CACHING_RETENTION_MINUTES * 60:
|
||||
mc_pairs = self.node.query_mc()
|
||||
self.liquidity_hints.extend_with_mission_control(mc_pairs)
|
||||
self.save_liquidty_hints()
|
||||
|
||||
@profiled
|
||||
def save_liquidty_hints(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue