diff --git a/src/lib.rs b/src/lib.rs index c34f579ce1..18bd814f83 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -923,6 +923,7 @@ impl Node { pub fn prober(&self) -> Prober { Prober::new( Arc::clone(&self.channel_manager), + Arc::clone(&self.chain_monitor), Arc::clone(&self.router), Arc::clone(&self.scorer), Arc::clone(&self.network_graph), diff --git a/src/logger.rs b/src/logger.rs index 9651fcb52e..7a329fae64 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -215,4 +215,4 @@ impl LdkLogger for Logger { }, } } -} \ No newline at end of file +} diff --git a/src/prober.rs b/src/prober.rs index db5c0cf50a..0e11e57699 100644 --- a/src/prober.rs +++ b/src/prober.rs @@ -14,9 +14,11 @@ use crate::{ error::Error, logger::Logger, types::{ChannelManager, Graph, Router, Scorer}, + ChainMonitor, }; use bitcoin::secp256k1::PublicKey; use lightning::{ + chain::transaction::OutPoint, io::Cursor, ln::{channel_state::ChannelDetails, channelmanager::PaymentId}, log_error, @@ -46,6 +48,7 @@ pub struct ProbabilisticScoringParameters { /// The Prober can be used to send probes to a destination node outside of regular payment flows. pub struct Prober { channel_manager: Arc, + chain_monitor: Arc, router: Arc, scorer: Arc>, network_graph: Arc, @@ -55,10 +58,11 @@ pub struct Prober { impl Prober { pub(crate) fn new( - channel_manager: Arc, router: Arc, scorer: Arc>, - network_graph: Arc, logger: Arc, node_id: PublicKey, + channel_manager: Arc, chain_monitor: Arc, + router: Arc, scorer: Arc>, network_graph: Arc, + logger: Arc, node_id: PublicKey, ) -> Self { - Self { channel_manager, router, scorer, network_graph, logger, node_id } + Self { channel_manager, chain_monitor, router, scorer, network_graph, logger, node_id } } /// Find a route from the node to a given destination on the network. @@ -87,6 +91,20 @@ impl Prober { }) } + /// Returns the latest update ids of the channel monitors. At some point after many updates the probes will start to get slow. + pub fn channel_monitor_update_ids(&self) -> Vec<(OutPoint, u64)> { + self.chain_monitor + .list_monitors() + .iter() + .filter_map(|(outpoint, _)| { + self.chain_monitor + .get_monitor(*outpoint) + .map(|monitor| (*outpoint, monitor.get_latest_update_id())) + .ok() + }) + .collect() + } + /// Updates the scoring decay parameters while retaining channel liquidity information.. pub fn update_scoring_decay_params( &self, decay_params: ProbabilisticScoringDecayParameters, diff --git a/tests/common/mod.rs b/tests/common/mod.rs index e27f9e9b83..0c0c24b7cd 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -8,7 +8,7 @@ #![cfg(any(test, cln_test, vss_test))] #![allow(dead_code)] -use ldk_node::config::{Config, EsploraSyncConfig, LoggingConfig}; +use ldk_node::config::{Config, EsploraSyncConfig}; use ldk_node::io::sqlite_store::SqliteStore; use ldk_node::logger::LogLevel; use ldk_node::payment::{PaymentDirection, PaymentKind, PaymentStatus};