Skip to content

Commit fb299f0

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 fb299f0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

bindings/ldk_node.udl

+2
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ 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+
[Throws=NodeError]
130+
bytes export_pathfinding_scores();
129131
};
130132

131133
[Enum]

src/lib.rs

+15-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,21 @@ 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) -> Result<Vec<u8>, Error> {
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+
.map_err(|e| {
1521+
log_error!(self.logger, "Failed to export pathfinding scores: {}", e);
1522+
Error::PersistenceFailed
1523+
})
1524+
}
15121525
}
15131526

15141527
impl Drop for Node {

0 commit comments

Comments
 (0)