Skip to content

Commit 3e87194

Browse files
committed
Rename lightning-liquidity's LSPS1 things to avoid conflicts
In general it kinda sucks to export multiple enums/structs as the same name, event across multiple modules/crates as it could cause downstream users to have to use overly verbose fully qualified types. More importantly, however, we cannot express multiple things under the same name in bindings (as we ultimately export to C which has a single, global, namespace). Here we rename several structs in `lightning-liquidity`'s LSPS1 module to avoid clashing with `lightning-liqudity`'s LSPS2 structs.
1 parent f3085bb commit 3e87194

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

lightning-liquidity/src/lsps1/client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
use super::event::LSPS1ClientEvent;
1313
use super::msgs::{
14-
CreateOrderRequest, CreateOrderResponse, GetInfoRequest, GetInfoResponse, GetOrderRequest,
14+
CreateOrderRequest, CreateOrderResponse, LSPS1GetInfoRequest, LSPS1GetInfoResponse, GetOrderRequest,
1515
LSPS1Message, LSPS1Request, LSPS1Response, OrderId, OrderParameters,
1616
};
1717
use crate::message_queue::MessageQueue;
@@ -94,14 +94,14 @@ where
9494
peer_state_lock.pending_get_info_requests.insert(request_id.clone());
9595
}
9696

97-
let request = LSPS1Request::GetInfo(GetInfoRequest {});
97+
let request = LSPS1Request::GetInfo(LSPS1GetInfoRequest {});
9898
let msg = LSPS1Message::Request(request_id.clone(), request).into();
9999
self.pending_messages.enqueue(&counterparty_node_id, msg);
100100
request_id
101101
}
102102

103103
fn handle_get_info_response(
104-
&self, request_id: RequestId, counterparty_node_id: &PublicKey, result: GetInfoResponse,
104+
&self, request_id: RequestId, counterparty_node_id: &PublicKey, result: LSPS1GetInfoResponse,
105105
) -> Result<(), LightningError> {
106106
let outer_state_lock = self.per_peer_state.write().unwrap();
107107

lightning-liquidity/src/lsps1/event.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! Contains LSPS1 event types
1111
1212
use super::msgs::OrderId;
13-
use super::msgs::{ChannelInfo, LSPS1Options, OrderParameters, PaymentInfo};
13+
use super::msgs::{LSPS1ChannelInfo, LSPS1Options, OrderParameters, PaymentInfo};
1414

1515
use crate::lsps0::ser::{RequestId, ResponseError};
1616

@@ -84,7 +84,7 @@ pub enum LSPS1ClientEvent {
8484
/// The details regarding payment of the order
8585
payment: PaymentInfo,
8686
/// The details regarding state of the channel ordered.
87-
channel: Option<ChannelInfo>,
87+
channel: Option<LSPS1ChannelInfo>,
8888
},
8989
/// Information from the LSP about the status of a previously created order.
9090
///
@@ -108,7 +108,7 @@ pub enum LSPS1ClientEvent {
108108
/// The details regarding payment of the order
109109
payment: PaymentInfo,
110110
/// The details regarding state of the channel ordered.
111-
channel: Option<ChannelInfo>,
111+
channel: Option<LSPS1ChannelInfo>,
112112
},
113113
/// A request previously issued via [`LSPS1ClientHandler::create_order`] or [`LSPS1ClientHandler::check_order_status`].
114114
/// failed as the LSP returned an error response.

lightning-liquidity/src/lsps1/msgs.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct OrderId(pub String);
3535
/// for more information.
3636
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, Default)]
3737
#[serde(default)]
38-
pub struct GetInfoRequest {}
38+
pub struct LSPS1GetInfoRequest {}
3939

4040
/// An object representing the supported protocol options.
4141
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
@@ -68,9 +68,9 @@ pub struct LSPS1Options {
6868
pub max_channel_balance_sat: u64,
6969
}
7070

71-
/// A response to a [`GetInfoRequest`].
71+
/// A response to a [`LSPS1GetInfoRequest`].
7272
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
73-
pub struct GetInfoResponse {
73+
pub struct LSPS1GetInfoResponse {
7474
/// All options supported by the LSP.
7575
#[serde(flatten)]
7676
pub options: LSPS1Options,
@@ -131,7 +131,7 @@ pub struct CreateOrderResponse {
131131
/// Contains details about how to pay for the order.
132132
pub payment: PaymentInfo,
133133
/// Contains information about the channel state.
134-
pub channel: Option<ChannelInfo>,
134+
pub channel: Option<LSPS1ChannelInfo>,
135135
}
136136

137137
/// An object representing the state of an order.
@@ -233,7 +233,7 @@ pub struct OnchainPayment {
233233

234234
/// Details regarding the state of an ordered channel.
235235
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
236-
pub struct ChannelInfo {
236+
pub struct LSPS1ChannelInfo {
237237
/// The datetime when the funding transaction has been published.
238238
pub funded_at: chrono::DateTime<Utc>,
239239
/// The outpoint of the funding transaction.
@@ -256,7 +256,7 @@ pub struct GetOrderRequest {
256256
#[derive(Clone, Debug, PartialEq, Eq)]
257257
pub enum LSPS1Request {
258258
/// A request to learn about the options supported by the LSP.
259-
GetInfo(GetInfoRequest),
259+
GetInfo(LSPS1GetInfoRequest),
260260
/// A request to create a channel order.
261261
CreateOrder(CreateOrderRequest),
262262
/// A request to query a previously created channel order.
@@ -266,9 +266,9 @@ pub enum LSPS1Request {
266266
/// An enum that captures all the valid JSON-RPC responses in the LSPS1 protocol.
267267
#[derive(Clone, Debug, PartialEq, Eq)]
268268
pub enum LSPS1Response {
269-
/// A successful response to a [`GetInfoRequest`].
270-
GetInfo(GetInfoResponse),
271-
/// An error response to a [`GetInfoRequest`].
269+
/// A successful response to a [`LSPS1GetInfoRequest`].
270+
GetInfo(LSPS1GetInfoResponse),
271+
/// An error response to a [`LSPS1GetInfoRequest`].
272272
GetInfoError(ResponseError),
273273
/// A successful response to a [`CreateOrderRequest`].
274274
CreateOrder(CreateOrderResponse),
@@ -460,7 +460,7 @@ mod tests {
460460
"funding_outpoint": "0301e0480b374b32851a9462db29dc19fe830a7f7d7a88b81612b9d42099c0ae:0",
461461
"expires_at": "2012-04-23T18:25:43.511Z"
462462
}"#;
463-
let _channel: ChannelInfo = serde_json::from_str(json_str).unwrap();
463+
let _channel: LSPS1ChannelInfo = serde_json::from_str(json_str).unwrap();
464464

465465
let json_str = r#""CANCELLED""#;
466466
let payment_state: PaymentState = serde_json::from_str(json_str).unwrap();

lightning-liquidity/src/lsps1/service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
use super::event::LSPS1ServiceEvent;
1313
use super::msgs::{
14-
ChannelInfo, CreateOrderRequest, CreateOrderResponse, GetInfoResponse, GetOrderRequest,
14+
LSPS1ChannelInfo, CreateOrderRequest, CreateOrderResponse, GetInfoResponse, GetOrderRequest,
1515
LSPS1Message, LSPS1Options, LSPS1Request, LSPS1Response, OrderId, OrderParameters, OrderState,
1616
PaymentInfo, LSPS1_CREATE_ORDER_REQUEST_ORDER_MISMATCH_ERROR_CODE,
1717
};
@@ -364,7 +364,7 @@ where
364364
/// [`LSPS1ServiceEvent::CheckPaymentConfirmation`]: crate::lsps1::event::LSPS1ServiceEvent::CheckPaymentConfirmation
365365
pub fn update_order_status(
366366
&self, request_id: RequestId, counterparty_node_id: PublicKey, order_id: OrderId,
367-
order_state: OrderState, channel: Option<ChannelInfo>,
367+
order_state: OrderState, channel: Option<LSPS1ChannelInfo>,
368368
) -> Result<(), APIError> {
369369
let (result, response) = {
370370
let outer_state_lock = self.per_peer_state.read().unwrap();

0 commit comments

Comments
 (0)