Skip to content
Open
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
4 changes: 3 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"02abc123...@1.2.3.4:9735"
],
"amount_msats": [1000, 10000, 100000, 1000000],
"timeout_sec": 60
"timeout_sec": 60,
"probe_delay_sec": 1,
"peer_delay_sec": 2
}
}
4 changes: 3 additions & 1 deletion prober_config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"037d8e050899fa0732fdd6fc1e0d5d8d685c2093932a7e10dc5e6fab8a34ed1c43"
],
"probe_amount_msats": [1000, 10000000, 100000000, 500000000],
"probe_timeout_sec": 3
"probe_timeout_sec": 3,
"probe_delay_sec": 1,
"peer_delay_sec": 2
}
2 changes: 2 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub(crate) struct ProbingConfig {
pub(crate) peers: Vec<String>,
pub(crate) amount_msats: Vec<u64>,
pub(crate) timeout_sec: u64,
pub(crate) probe_delay_sec: u64,
pub(crate) peer_delay_sec: u64,
}

pub(crate) struct LdkUserInfo {
Expand Down
18 changes: 17 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub struct ProbingConfig {
pub amount_msats: Vec<u64>,
#[serde(default = "default_probe_timeout")]
pub timeout_sec: u64,
#[serde(default = "default_probe_delay")]
pub probe_delay_sec: u64,
#[serde(default = "default_peer_delay")]
pub peer_delay_sec: u64,
Comment on lines 64 to +69
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New config fields with serde defaults (probe_delay_sec, peer_delay_sec) change deserialization behavior. There are no tests around config parsing in this module; adding a small unit test to assert defaults are applied when these fields are omitted would help prevent accidental breaking changes to the config format.

Copilot uses AI. Check for mistakes.
}

// Default functions
Expand All @@ -86,6 +90,14 @@ fn default_probe_timeout() -> u64 {
60
}

fn default_probe_delay() -> u64 {
1
}

fn default_peer_delay() -> u64 {
2
}

impl Default for RapidGossipSyncConfig {
fn default() -> Self {
Self { enabled: true, url: None, interval_hours: 6 }
Expand Down Expand Up @@ -177,6 +189,8 @@ impl NodeConfig {
peers: p.peers,
amount_msats: p.amount_msats,
timeout_sec: p.timeout_sec,
probe_delay_sec: p.probe_delay_sec,
peer_delay_sec: p.peer_delay_sec,
});
LdkUserInfo {
bitcoind_rpc_username: self.bitcoind.rpc_username,
Expand Down Expand Up @@ -225,7 +239,9 @@ pub fn print_config_help() {
"interval_sec": 300,
"peers": [],
"amount_msats": [1000, 10000, 100000],
"timeout_sec": 60
"timeout_sec": 60,
"probe_delay_sec": 1,
"peer_delay_sec": 2
}}
}}"#
);
Expand Down
23 changes: 19 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1317,16 +1317,20 @@ async fn start_ldk() {
sorted_amounts.sort();

let probe_timeout = Duration::from_secs(probe_config.timeout_sec);
let probe_delay = Duration::from_secs(probe_config.probe_delay_sec);
let peer_delay = Duration::from_secs(probe_config.peer_delay_sec);

// Log startup configuration
lightning::log_info!(
&*probing_logger,
"Probing started: {} peers, {} amounts {:?} msat, interval={}s, timeout={}s",
"Probing started: {} peers, {} amounts {:?} msat, interval={}s, timeout={}s, probe_delay={}s, peer_delay={}s",
probe_config.peers.len(),
sorted_amounts.len(),
sorted_amounts,
probe_config.interval_sec,
probe_config.timeout_sec
probe_config.timeout_sec,
probe_config.probe_delay_sec,
probe_config.peer_delay_sec
);

tokio::spawn(async move {
Expand All @@ -1336,7 +1340,8 @@ async fn start_ldk() {
interval.tick().await;

// Probe each peer with amounts from smallest to largest
for peer in &probe_config.peers {
let peer_count = probe_config.peers.len();
for (peer_idx, peer) in probe_config.peers.iter().enumerate() {
let peer_short = truncate_pubkey(peer);
'amounts: for &amount in &sorted_amounts {
// Send the probe and get the payment hash
Expand Down Expand Up @@ -1373,7 +1378,8 @@ async fn start_ldk() {
amount,
hash
);
// Probe succeeded, continue to next amount
// Probe succeeded, sleep before next amount
tokio::time::sleep(probe_delay).await;
},
Ok(Ok(ProbeOutcome::Failed)) => {
lightning::log_warn!(
Expand All @@ -1383,6 +1389,7 @@ async fn start_ldk() {
amount,
hash
);
tokio::time::sleep(probe_delay).await;
break 'amounts;
},
Ok(Err(_)) => {
Expand All @@ -1393,6 +1400,7 @@ async fn start_ldk() {
amount,
hash
);
tokio::time::sleep(probe_delay).await;
break 'amounts;
},
Err(_) => {
Expand All @@ -1409,6 +1417,7 @@ async fn start_ldk() {
.unwrap()
.pending_probes
.remove(&hash);
tokio::time::sleep(probe_delay).await;
break 'amounts;
},
}
Expand All @@ -1419,9 +1428,15 @@ async fn start_ldk() {
peer_short,
amount
);
tokio::time::sleep(probe_delay).await;
break 'amounts;
}
}

// Sleep between peers (except after the last peer)
if peer_idx < peer_count - 1 {
tokio::time::sleep(peer_delay).await;
}
}
}
});
Expand Down