Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ impl LdkLogger for Logger {
},
}
}
}
}
24 changes: 21 additions & 3 deletions src/prober.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<ChannelManager>,
chain_monitor: Arc<ChainMonitor>,
router: Arc<Router>,
scorer: Arc<Mutex<Scorer>>,
network_graph: Arc<Graph>,
Expand All @@ -55,10 +58,11 @@ pub struct Prober {

impl Prober {
pub(crate) fn new(
channel_manager: Arc<ChannelManager>, router: Arc<Router>, scorer: Arc<Mutex<Scorer>>,
network_graph: Arc<Graph>, logger: Arc<Logger>, node_id: PublicKey,
channel_manager: Arc<ChannelManager>, chain_monitor: Arc<ChainMonitor>,
router: Arc<Router>, scorer: Arc<Mutex<Scorer>>, network_graph: Arc<Graph>,
logger: Arc<Logger>, 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.
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
Loading