Skip to content

Commit 5be9c1a

Browse files
committed
Rename lightning-liquidity's LSPS2 things to avoid confusion
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 LSPS2 similar to what we did with LSPS1 structs in the previous commit to avoid having unprefixed and prefixed structs with the same name in `lightning-liquidity`.
1 parent 3e87194 commit 5be9c1a

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

lightning-liquidity/src/lsps2/client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use core::default::Default;
2626
use core::ops::Deref;
2727

2828
use crate::lsps2::msgs::{
29-
BuyRequest, BuyResponse, GetInfoRequest, GetInfoResponse, LSPS2Message, LSPS2Request,
29+
BuyRequest, BuyResponse, LSPS2GetInfoRequest, LSPS2GetInfoResponse, LSPS2Message, LSPS2Request,
3030
LSPS2Response, OpeningFeeParams,
3131
};
3232

@@ -122,7 +122,7 @@ where
122122
peer_state_lock.pending_get_info_requests.insert(request_id.clone());
123123
}
124124

125-
let request = LSPS2Request::GetInfo(GetInfoRequest { token });
125+
let request = LSPS2Request::GetInfo(LSPS2GetInfoRequest { token });
126126
let msg = LSPS2Message::Request(request_id.clone(), request).into();
127127
self.pending_messages.enqueue(&counterparty_node_id, msg);
128128

@@ -181,7 +181,7 @@ where
181181
}
182182

183183
fn handle_get_info_response(
184-
&self, request_id: RequestId, counterparty_node_id: &PublicKey, result: GetInfoResponse,
184+
&self, request_id: RequestId, counterparty_node_id: &PublicKey, result: LSPS2GetInfoResponse,
185185
) -> Result<(), LightningError> {
186186
let outer_state_lock = self.per_peer_state.read().unwrap();
187187
match outer_state_lock.get(counterparty_node_id) {

lightning-liquidity/src/lsps2/msgs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(crate) const LSPS2_BUY_REQUEST_PAYMENT_SIZE_TOO_LARGE_ERROR_CODE: i32 = 203;
2727

2828
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
2929
/// A request made to an LSP to learn their current channel fees and parameters.
30-
pub struct GetInfoRequest {
30+
pub struct LSPS2GetInfoRequest {
3131
/// An optional token to provide to the LSP.
3232
pub token: Option<String>,
3333
}
@@ -106,9 +106,9 @@ pub struct OpeningFeeParams {
106106
pub promise: String,
107107
}
108108

109-
/// A response to a [`GetInfoRequest`]
109+
/// A response to a [`LSPS2GetInfoRequest`]
110110
#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
111-
pub struct GetInfoResponse {
111+
pub struct LSPS2GetInfoResponse {
112112
/// A set of opening fee parameters.
113113
pub opening_fee_params_menu: Vec<OpeningFeeParams>,
114114
}
@@ -164,7 +164,7 @@ pub struct BuyResponse {
164164
/// An enum that captures all the valid JSON-RPC requests in the LSPS2 protocol.
165165
pub enum LSPS2Request {
166166
/// A request to learn an LSP's channel fees and parameters.
167-
GetInfo(GetInfoRequest),
167+
GetInfo(LSPS2GetInfoRequest),
168168
/// A request to buy a JIT channel from an LSP.
169169
Buy(BuyRequest),
170170
}
@@ -173,7 +173,7 @@ pub enum LSPS2Request {
173173
/// An enum that captures all the valid JSON-RPC responses in the LSPS2 protocol.
174174
pub enum LSPS2Response {
175175
/// A successful response to a [`LSPS2Request::GetInfo`] request.
176-
GetInfo(GetInfoResponse),
176+
GetInfo(LSPS2GetInfoResponse),
177177
/// An error response to a [`LSPS2Request::GetInfo`] request.
178178
GetInfoError(ResponseError),
179179
/// A successful response to a [`LSPS2Request::Buy`] request.

lightning-liquidity/src/lsps2/service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use core::ops::Deref;
4040
use core::sync::atomic::{AtomicUsize, Ordering};
4141

4242
use crate::lsps2::msgs::{
43-
BuyRequest, BuyResponse, GetInfoRequest, GetInfoResponse, LSPS2Message, LSPS2Request,
43+
BuyRequest, BuyResponse, LSPS2GetInfoRequest, LSPS2GetInfoResponse, LSPS2Message, LSPS2Request,
4444
LSPS2Response, OpeningFeeParams, RawOpeningFeeParams,
4545
LSPS2_BUY_REQUEST_INVALID_OPENING_FEE_PARAMS_ERROR_CODE,
4646
LSPS2_BUY_REQUEST_PAYMENT_SIZE_TOO_LARGE_ERROR_CODE,
@@ -658,7 +658,7 @@ where
658658

659659
match self.remove_pending_request(&mut peer_state_lock, &request_id) {
660660
Some(LSPS2Request::GetInfo(_)) => {
661-
let response = LSPS2Response::GetInfo(GetInfoResponse {
661+
let response = LSPS2Response::GetInfo(LSPS2GetInfoResponse {
662662
opening_fee_params_menu: opening_fee_params_menu
663663
.into_iter()
664664
.map(|param| {
@@ -1076,7 +1076,7 @@ where
10761076
}
10771077

10781078
fn handle_get_info_request(
1079-
&self, request_id: RequestId, counterparty_node_id: &PublicKey, params: GetInfoRequest,
1079+
&self, request_id: RequestId, counterparty_node_id: &PublicKey, params: LSPS2GetInfoRequest,
10801080
) -> Result<(), LightningError> {
10811081
let (result, response) = {
10821082
let mut outer_state_lock = self.per_peer_state.write().unwrap();

0 commit comments

Comments
 (0)