Skip to content

Commit 5e9413d

Browse files
committed
Add pathfinding scores export method
The exported scores can be shared with light nodes and used to improve pathfinding when only a limited local view on the network is available.
1 parent 8bfa8ec commit 5e9413d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

bindings/ldk_node.udl

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ interface Node {
126126
NetworkGraph network_graph();
127127
string sign_message([ByRef]sequence<u8> msg);
128128
boolean verify_signature([ByRef]sequence<u8> msg, [ByRef]string sig, [ByRef]PublicKey pkey);
129+
bytes export_pathfinding_scores();
129130
};
130131

131132
[Enum]

src/lib.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ mod wallet;
9999
pub use bip39;
100100
pub use bitcoin;
101101
pub use lightning;
102-
pub use lightning_invoice;
103-
pub use lightning_types;
104102
pub use vss_client;
105103

106104
pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
@@ -1509,6 +1507,18 @@ impl Node {
15091507
pub fn verify_signature(&self, msg: &[u8], sig: &str, pkey: &PublicKey) -> bool {
15101508
self.keys_manager.verify_signature(msg, sig, pkey)
15111509
}
1510+
1511+
/// Exports the current state of the scorer. The result can be shared with and merged by light nodes that only have
1512+
/// a limited view of the network.
1513+
pub fn export_pathfinding_scores(&self) -> Vec<u8> {
1514+
self.kv_store
1515+
.read(
1516+
lightning::util::persist::SCORER_PERSISTENCE_PRIMARY_NAMESPACE,
1517+
lightning::util::persist::SCORER_PERSISTENCE_SECONDARY_NAMESPACE,
1518+
lightning::util::persist::SCORER_PERSISTENCE_KEY,
1519+
)
1520+
.unwrap()
1521+
}
15121522
}
15131523

15141524
impl Drop for Node {

0 commit comments

Comments
 (0)