Skip to content

Commit f40a007

Browse files
committed
Prefactor: Rename fields for clarity
Previously, we named internal fields/APIs `lspsX_service` as us being the client was implied. Since we're about to also add service-side functionalities, such naming would start to get confusing. We hence rename them to follow a `lspsX_client` scheme, and will add the service-side APIs using the `service` terminology.
1 parent e9c435a commit f40a007

File tree

3 files changed

+105
-90
lines changed

3 files changed

+105
-90
lines changed

src/builder.rs

+34-16
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,26 @@ enum GossipSourceConfig {
9494
RapidGossipSync(String),
9595
}
9696

97-
#[derive(Debug, Clone)]
97+
#[derive(Debug, Clone, Default)]
9898
struct LiquiditySourceConfig {
99-
// LSPS1 service's (node_id, address, token)
100-
lsps1_service: Option<(PublicKey, SocketAddress, Option<String>)>,
101-
// LSPS2 service's (node_id, address, token)
102-
lsps2_service: Option<(PublicKey, SocketAddress, Option<String>)>,
99+
// Act as an LSPS1 client connecting to the given service.
100+
lsps1_client: Option<LSPS1ClientConfig>,
101+
// Act as an LSPS2 client connecting to the given service.
102+
lsps2_client: Option<LSPS2ClientConfig>,
103103
}
104104

105-
impl Default for LiquiditySourceConfig {
106-
fn default() -> Self {
107-
Self { lsps1_service: None, lsps2_service: None }
108-
}
105+
#[derive(Debug, Clone)]
106+
struct LSPS1ClientConfig {
107+
node_id: PublicKey,
108+
address: SocketAddress,
109+
token: Option<String>,
110+
}
111+
112+
#[derive(Debug, Clone)]
113+
struct LSPS2ClientConfig {
114+
node_id: PublicKey,
115+
address: SocketAddress,
116+
token: Option<String>,
109117
}
110118

111119
#[derive(Clone)]
@@ -319,7 +327,8 @@ impl NodeBuilder {
319327

320328
let liquidity_source_config =
321329
self.liquidity_source_config.get_or_insert(LiquiditySourceConfig::default());
322-
liquidity_source_config.lsps1_service = Some((node_id, address, token));
330+
let lsps1_client_config = LSPS1ClientConfig { node_id, address, token };
331+
liquidity_source_config.lsps1_client = Some(lsps1_client_config);
323332
self
324333
}
325334

@@ -339,7 +348,8 @@ impl NodeBuilder {
339348

340349
let liquidity_source_config =
341350
self.liquidity_source_config.get_or_insert(LiquiditySourceConfig::default());
342-
liquidity_source_config.lsps2_service = Some((node_id, address, token));
351+
let lsps2_client_config = LSPS2ClientConfig { node_id, address, token };
352+
liquidity_source_config.lsps2_client = Some(lsps2_client_config);
343353
self
344354
}
345355

@@ -1039,7 +1049,7 @@ fn build_with_store_internal(
10391049
};
10401050

10411051
let mut user_config = default_user_config(&config);
1042-
if liquidity_source_config.and_then(|lsc| lsc.lsps2_service.as_ref()).is_some() {
1052+
if liquidity_source_config.and_then(|lsc| lsc.lsps2_client.as_ref()).is_some() {
10431053
// Generally allow claiming underpaying HTLCs as the LSP will skim off some fee. We'll
10441054
// check that they don't take too much before claiming.
10451055
user_config.channel_config.accept_underpaying_htlcs = true;
@@ -1180,12 +1190,20 @@ fn build_with_store_internal(
11801190
Arc::clone(&logger),
11811191
);
11821192

1183-
lsc.lsps1_service.as_ref().map(|(node_id, address, token)| {
1184-
liquidity_source_builder.lsps1_service(*node_id, address.clone(), token.clone())
1193+
lsc.lsps1_client.as_ref().map(|config| {
1194+
liquidity_source_builder.lsps1_client(
1195+
config.node_id,
1196+
config.address.clone(),
1197+
config.token.clone(),
1198+
)
11851199
});
11861200

1187-
lsc.lsps2_service.as_ref().map(|(node_id, address, token)| {
1188-
liquidity_source_builder.lsps2_service(*node_id, address.clone(), token.clone())
1201+
lsc.lsps2_client.as_ref().map(|config| {
1202+
liquidity_source_builder.lsps2_client(
1203+
config.node_id,
1204+
config.address.clone(),
1205+
config.token.clone(),
1206+
)
11891207
});
11901208

11911209
Arc::new(liquidity_source_builder.build())

0 commit comments

Comments
 (0)