Skip to content

Add pathfinding scores export method #458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2025
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
2 changes: 2 additions & 0 deletions bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ interface Node {
NetworkGraph network_graph();
string sign_message([ByRef]sequence<u8> msg);
boolean verify_signature([ByRef]sequence<u8> msg, [ByRef]string sig, [ByRef]PublicKey pkey);
[Throws=NodeError]
bytes export_pathfinding_scores();
};

[Enum]
Expand Down
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,25 @@ impl Node {
pub fn verify_signature(&self, msg: &[u8], sig: &str, pkey: &PublicKey) -> bool {
self.keys_manager.verify_signature(msg, sig, pkey)
}

/// Exports the current state of the scorer. The result can be shared with and merged by light nodes that only have
/// a limited view of the network.
pub fn export_pathfinding_scores(&self) -> Result<Vec<u8>, Error> {
self.kv_store
.read(
lightning::util::persist::SCORER_PERSISTENCE_PRIMARY_NAMESPACE,
lightning::util::persist::SCORER_PERSISTENCE_SECONDARY_NAMESPACE,
lightning::util::persist::SCORER_PERSISTENCE_KEY,
)
.map_err(|e| {
log_error!(
self.logger,
"Failed to access store while exporting pathfinding scores: {}",
e
);
Error::PersistenceFailed
})
}
}

impl Drop for Node {
Expand Down
Loading