Skip to content

Commit

Permalink
fixup! Add Api impl for ListForwardedPayments.
Browse files Browse the repository at this point in the history
  • Loading branch information
G8XSU committed Dec 11, 2024
1 parent 02b749a commit 5ef7584
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 0 additions & 2 deletions ldk-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ ldk-server-protos = { path = "../ldk-server-protos" }
bytes = "1.4.0"
hex = { package = "hex-conservative", version = "0.2.1", default-features = false }
rusqlite = { version = "0.31.0", features = ["bundled"] }

[dev-dependencies]
rand = "0.8.5"
5 changes: 3 additions & 2 deletions ldk-server/src/api/list_forwarded_payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::io::{
FORWARDED_PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE,
};
use crate::service::Context;
use bytes::Bytes;
use ldk_server_protos::api::{ListForwardedPaymentsRequest, ListForwardedPaymentsResponse};
use ldk_server_protos::types::{ForwardedPayment, PageToken};
use prost::Message;
Expand Down Expand Up @@ -33,15 +34,15 @@ pub(crate) fn handle_list_forwarded_payments_request(
&key,
)
.map_err(|_| ldk_node::NodeError::ConnectionFailed)?;
let forwarded_payment = ForwardedPayment::decode(&forwarded_payment_bytes)
let forwarded_payment = ForwardedPayment::decode(Bytes::from(forwarded_payment_bytes))
.map_err(|_| ldk_node::NodeError::ConnectionFailed)?;
forwarded_payments.push(forwarded_payment);
}
let response = ListForwardedPaymentsResponse {
forwarded_payments,
next_page_token: list_response
.next_page_token
.map(|(token, index)| Some(PageToken { token, index })),
.map(|(token, index)| PageToken { token, index }),
};
Ok(response)
}
2 changes: 1 addition & 1 deletion ldk-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn main() {
match res {
Ok((stream, _)) => {
let io_stream = TokioIo::new(stream);
let node_service = NodeService::new(Arc::clone(&node), Arc::clone(&paginated_store) as Arc<dyn PaginatedKVStore>);
let node_service = NodeService::new(Arc::clone(&node), Arc::clone(&paginated_store) as Arc<dyn PaginatedKVStore + Send + Sync>);
runtime.spawn(async move {
if let Err(err) = http1::Builder::new().serve_connection(io_stream, node_service).await {
eprintln!("Failed to serve connection: {}", err);
Expand Down
4 changes: 3 additions & 1 deletion ldk-server/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ pub struct NodeService {
}

impl NodeService {
pub(crate) fn new(node: Arc<Node>, paginated_kv_store: Arc<dyn PaginatedKVStore>) -> Self {
pub(crate) fn new(
node: Arc<Node>, paginated_kv_store: Arc<dyn PaginatedKVStore + Send + Sync>,
) -> Self {
Self { context: Arc::new(Context { node, paginated_kv_store }) }
}
}
Expand Down

0 comments on commit 5ef7584

Please sign in to comment.