Skip to content

Commit b1f7c48

Browse files
committed
Allow disabling the scorer with an empty URL
Treat an explicitly empty pathfinding scores source as absent so users can opt out of the mainnet default through config inputs. This commit was prepared with OpenAI Codex.
1 parent 9407078 commit b1f7c48

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

contrib/ldk-server-config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ listening_addresses = ["localhost:9735"] # Lightning node listening address
55
#announcement_addresses = ["54.3.7.81:9735"] # Lightning node announcement addresses
66
#grpc_service_address = "127.0.0.1:3536" # LDK Server gRPC address (optional, defaults to 127.0.0.1:3536)
77
alias = "ldk_server" # Lightning node alias
8-
#pathfinding_scores_source_url = "https://rapidsync.lightningdevkit.org/scoring/scorer.bin" # External pathfinding scores source (optional, defaults to this URL on mainnet)
8+
#pathfinding_scores_source_url = "https://rapidsync.lightningdevkit.org/scoring/scorer.bin" # External pathfinding scores source (optional, defaults to this URL on mainnet; set to "" to disable)
99
#rgs_server_url = "https://rapidsync.lightningdevkit.org/snapshot/v2/" # Optional: RGS URL for rapid gossip sync
1010
#async_payments_role = "client" # Optional async payments role: "client" or "server"
1111

ldk-server/src/util/config.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ impl ConfigBuilder {
485485
let lsps2_service_config = None;
486486

487487
let pathfinding_scores_source_url = match self.pathfinding_scores_source_url {
488+
Some(url) if url.is_empty() => None,
488489
Some(url) => Some(url),
489490
None if network == Network::Bitcoin => {
490491
Some(DEFAULT_PATHFINDING_SCORES_SOURCE_URL.to_string())
@@ -968,7 +969,7 @@ pub struct ArgsConfig {
968969
#[arg(
969970
long,
970971
env = "LDK_SERVER_PATHFINDING_SCORES_SOURCE_URL",
971-
help = "The external scores source that is merged into the local scoring system to improve routing. Defaults to https://rapidsync.lightningdevkit.org/scoring/scorer.bin on mainnet."
972+
help = "The external scores source that is merged into the local scoring system to improve routing. Defaults to https://rapidsync.lightningdevkit.org/scoring/scorer.bin on mainnet. Set to an empty string to disable."
972973
)]
973974
pathfinding_scores_source_url: Option<String>,
974975

@@ -1547,6 +1548,26 @@ mod tests {
15471548
);
15481549
}
15491550

1551+
#[test]
1552+
fn test_empty_pathfinding_scores_source_url_disables_source() {
1553+
let storage_path = std::env::temp_dir();
1554+
let config_file_name = "test_empty_pathfinding_scores_source_url.toml";
1555+
let toml_config = DEFAULT_CONFIG.replace(
1556+
"alias = \"LDK Server\"",
1557+
"alias = \"LDK Server\"\npathfinding_scores_source_url = \"\"",
1558+
);
1559+
fs::write(storage_path.join(config_file_name), toml_config).unwrap();
1560+
1561+
let mut args_config = empty_args_config();
1562+
args_config.config_file =
1563+
Some(storage_path.join(config_file_name).to_string_lossy().to_string());
1564+
args_config.node_network = Some(Network::Bitcoin);
1565+
1566+
let config = load_config(&args_config).unwrap();
1567+
1568+
assert_eq!(config.pathfinding_scores_source_url, None);
1569+
}
1570+
15501571
#[test]
15511572
fn test_config_missing_fields_in_file() {
15521573
let storage_path = std::env::temp_dir();

0 commit comments

Comments
 (0)