@@ -94,18 +94,26 @@ enum GossipSourceConfig {
94
94
RapidGossipSync ( String ) ,
95
95
}
96
96
97
- #[ derive( Debug , Clone ) ]
97
+ #[ derive( Debug , Clone , Default ) ]
98
98
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 > ,
103
103
}
104
104
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 > ,
109
117
}
110
118
111
119
#[ derive( Clone ) ]
@@ -319,7 +327,8 @@ impl NodeBuilder {
319
327
320
328
let liquidity_source_config =
321
329
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) ;
323
332
self
324
333
}
325
334
@@ -339,7 +348,8 @@ impl NodeBuilder {
339
348
340
349
let liquidity_source_config =
341
350
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) ;
343
353
self
344
354
}
345
355
@@ -1039,7 +1049,7 @@ fn build_with_store_internal(
1039
1049
} ;
1040
1050
1041
1051
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 ( ) {
1043
1053
// Generally allow claiming underpaying HTLCs as the LSP will skim off some fee. We'll
1044
1054
// check that they don't take too much before claiming.
1045
1055
user_config. channel_config . accept_underpaying_htlcs = true ;
@@ -1180,12 +1190,20 @@ fn build_with_store_internal(
1180
1190
Arc :: clone ( & logger) ,
1181
1191
) ;
1182
1192
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
+ )
1185
1199
} ) ;
1186
1200
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
+ )
1189
1207
} ) ;
1190
1208
1191
1209
Arc :: new ( liquidity_source_builder. build ( ) )
0 commit comments