Skip to content

Commit 685c5b6

Browse files
committed
Reorder LSPS2 API params
.. to align with the rest of the APIs where we usually go `node_id`, `address`, etc.
1 parent 3b36020 commit 685c5b6

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

bindings/ldk_node.udl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ interface Builder {
5858
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
5959
void set_gossip_source_p2p();
6060
void set_gossip_source_rgs(string rgs_server_url);
61-
void set_liquidity_source_lsps2(SocketAddress address, PublicKey node_id, string? token);
61+
void set_liquidity_source_lsps2(PublicKey node_id, SocketAddress address, string? token);
6262
void set_storage_dir_path(string storage_dir_path);
6363
void set_filesystem_logger(string? log_file_path, LogLevel? log_level);
6464
void set_log_facade_logger(LogLevel log_level);

src/builder.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ enum GossipSourceConfig {
9999

100100
#[derive(Debug, Clone)]
101101
struct LiquiditySourceConfig {
102-
// LSPS2 service's (address, node_id, token)
103-
lsps2_service: Option<(SocketAddress, PublicKey, Option<String>)>,
102+
// LSPS2 service's (node_id, address, token)
103+
lsps2_service: Option<(PublicKey, SocketAddress, Option<String>)>,
104104
}
105105

106106
impl Default for LiquiditySourceConfig {
@@ -310,14 +310,14 @@ impl NodeBuilder {
310310
///
311311
/// The given `token` will be used by the LSP to authenticate the user.
312312
pub fn set_liquidity_source_lsps2(
313-
&mut self, address: SocketAddress, node_id: PublicKey, token: Option<String>,
313+
&mut self, node_id: PublicKey, address: SocketAddress, token: Option<String>,
314314
) -> &mut Self {
315315
// Mark the LSP as trusted for 0conf
316316
self.config.trusted_peers_0conf.push(node_id.clone());
317317

318318
let liquidity_source_config =
319319
self.liquidity_source_config.get_or_insert(LiquiditySourceConfig::default());
320-
liquidity_source_config.lsps2_service = Some((address, node_id, token));
320+
liquidity_source_config.lsps2_service = Some((node_id, address, token));
321321
self
322322
}
323323

@@ -644,9 +644,9 @@ impl ArcedNodeBuilder {
644644
///
645645
/// The given `token` will be used by the LSP to authenticate the user.
646646
pub fn set_liquidity_source_lsps2(
647-
&self, address: SocketAddress, node_id: PublicKey, token: Option<String>,
647+
&self, node_id: PublicKey, address: SocketAddress, token: Option<String>,
648648
) {
649-
self.inner.write().unwrap().set_liquidity_source_lsps2(address, node_id, token);
649+
self.inner.write().unwrap().set_liquidity_source_lsps2(node_id, address, token);
650650
}
651651

652652
/// Sets the used storage directory path.
@@ -1125,7 +1125,7 @@ fn build_with_store_internal(
11251125
};
11261126

11271127
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
1128-
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
1128+
lsc.lsps2_service.as_ref().map(|(node_id, address, token)| {
11291129
let lsps2_client_config = Some(LSPS2ClientConfig {});
11301130
let liquidity_client_config =
11311131
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
@@ -1138,8 +1138,8 @@ fn build_with_store_internal(
11381138
liquidity_client_config,
11391139
));
11401140
Arc::new(LiquiditySource::new_lsps2(
1141-
address.clone(),
11421141
*node_id,
1142+
address.clone(),
11431143
token.clone(),
11441144
Arc::clone(&channel_manager),
11451145
Arc::clone(&keys_manager),

src/liquidity.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use std::time::Duration;
3232
const LIQUIDITY_REQUEST_TIMEOUT_SECS: u64 = 5;
3333

3434
struct LSPS2Service {
35-
address: SocketAddress,
3635
node_id: PublicKey,
36+
address: SocketAddress,
3737
token: Option<String>,
3838
pending_fee_requests: Mutex<HashMap<RequestId, oneshot::Sender<LSPS2FeeResponse>>>,
3939
pending_buy_requests: Mutex<HashMap<RequestId, oneshot::Sender<LSPS2BuyResponse>>>,
@@ -56,15 +56,15 @@ where
5656
L::Target: LdkLogger,
5757
{
5858
pub(crate) fn new_lsps2(
59-
address: SocketAddress, node_id: PublicKey, token: Option<String>,
59+
node_id: PublicKey, address: SocketAddress, token: Option<String>,
6060
channel_manager: Arc<ChannelManager>, keys_manager: Arc<KeysManager>,
6161
liquidity_manager: Arc<LiquidityManager>, config: Arc<Config>, logger: L,
6262
) -> Self {
6363
let pending_fee_requests = Mutex::new(HashMap::new());
6464
let pending_buy_requests = Mutex::new(HashMap::new());
6565
let lsps2_service = Some(LSPS2Service {
66-
address,
6766
node_id,
67+
address,
6868
token,
6969
pending_fee_requests,
7070
pending_buy_requests,

0 commit comments

Comments
 (0)