Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 111ab58

Browse files
committed
Expose lsps_message_handler and return response
1 parent f3e3234 commit 111ab58

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

src/transport/message_handler.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ pub struct LiquidityManager<
6767
pending_messages: Arc<Mutex<Vec<(PublicKey, LSPSMessage)>>>,
6868
pending_events: Arc<EventQueue>,
6969
request_id_to_method_map: Mutex<HashMap<String, String>>,
70-
lsps0_message_handler: LSPS0MessageHandler<ES>,
70+
/// lsps0 message handler
71+
pub lsps0_message_handler: LSPS0MessageHandler<ES>,
7172
provider_config: Option<LiquidityProviderConfig>,
7273
channel_manager: Arc<ChannelManager<M, T, ES, NS, SP, F, R, L>>,
7374
}

src/transport/protocol.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,21 @@ where
4545
self.pending_messages.lock().unwrap().push((counterparty_node_id, message.into()));
4646
}
4747

48-
fn handle_request(
48+
/// Return LSPS0Response
49+
///
50+
/// Typically the return will not send out to any where just for verification or inspectation
51+
/// in service for advanced features or logging
52+
pub fn handle_request(
4953
&self, request_id: RequestId, request: LSPS0Request, counterparty_node_id: &PublicKey,
50-
) -> Result<(), lightning::ln::msgs::LightningError> {
54+
) -> Result<LSPS0Response, lightning::ln::msgs::LightningError> {
5155
match request {
5256
LSPS0Request::ListProtocols(_) => {
53-
let msg = LSPS0Message::Response(
54-
request_id,
55-
LSPS0Response::ListProtocols(ListProtocolsResponse {
56-
protocols: self.protocols.clone(),
57-
}),
58-
);
57+
let resp = LSPS0Response::ListProtocols(ListProtocolsResponse {
58+
protocols: self.protocols.clone(),
59+
});
60+
let msg = LSPS0Message::Response(request_id, resp.clone());
5961
self.enqueue_message(*counterparty_node_id, msg);
60-
Ok(())
62+
Ok(resp)
6163
}
6264
}
6365
}
@@ -92,7 +94,8 @@ where
9294
) -> Result<(), LightningError> {
9395
match message {
9496
LSPS0Message::Request(request_id, request) => {
95-
self.handle_request(request_id, request, counterparty_node_id)
97+
self.handle_request(request_id, request, counterparty_node_id)?;
98+
Ok(())
9699
}
97100
LSPS0Message::Response(_, response) => {
98101
self.handle_response(response, counterparty_node_id)

0 commit comments

Comments
 (0)