Skip to content

Commit 2027530

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 20a6927 commit 2027530

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
@@ -39,7 +39,7 @@ interface Builder {
3939
void set_chain_source_bitcoind_rpc(string rpc_host, u16 rpc_port, string rpc_user, string rpc_password);
4040
void set_gossip_source_p2p();
4141
void set_gossip_source_rgs(string rgs_server_url);
42-
void set_liquidity_source_lsps2(SocketAddress address, PublicKey node_id, string? token);
42+
void set_liquidity_source_lsps2(PublicKey node_id, SocketAddress address, string? token);
4343
void set_storage_dir_path(string storage_dir_path);
4444
void set_network(Network network);
4545
[Throws=BuildError]

src/builder.rs

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

9797
#[derive(Debug, Clone)]
9898
struct LiquiditySourceConfig {
99-
// LSPS2 service's (address, node_id, token)
100-
lsps2_service: Option<(SocketAddress, PublicKey, Option<String>)>,
99+
// LSPS2 service's (node_id, address, token)
100+
lsps2_service: Option<(PublicKey, SocketAddress, Option<String>)>,
101101
}
102102

103103
impl Default for LiquiditySourceConfig {
@@ -281,14 +281,14 @@ impl NodeBuilder {
281281
///
282282
/// The given `token` will be used by the LSP to authenticate the user.
283283
pub fn set_liquidity_source_lsps2(
284-
&mut self, address: SocketAddress, node_id: PublicKey, token: Option<String>,
284+
&mut self, node_id: PublicKey, address: SocketAddress, token: Option<String>,
285285
) -> &mut Self {
286286
// Mark the LSP as trusted for 0conf
287287
self.config.trusted_peers_0conf.push(node_id.clone());
288288

289289
let liquidity_source_config =
290290
self.liquidity_source_config.get_or_insert(LiquiditySourceConfig::default());
291-
liquidity_source_config.lsps2_service = Some((address, node_id, token));
291+
liquidity_source_config.lsps2_service = Some((node_id, address, token));
292292
self
293293
}
294294

@@ -600,9 +600,9 @@ impl ArcedNodeBuilder {
600600
///
601601
/// The given `token` will be used by the LSP to authenticate the user.
602602
pub fn set_liquidity_source_lsps2(
603-
&self, address: SocketAddress, node_id: PublicKey, token: Option<String>,
603+
&self, node_id: PublicKey, address: SocketAddress, token: Option<String>,
604604
) {
605-
self.inner.write().unwrap().set_liquidity_source_lsps2(address, node_id, token);
605+
self.inner.write().unwrap().set_liquidity_source_lsps2(node_id, address, token);
606606
}
607607

608608
/// Sets the used storage directory path.
@@ -1053,7 +1053,7 @@ fn build_with_store_internal(
10531053
};
10541054

10551055
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
1056-
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
1056+
lsc.lsps2_service.as_ref().map(|(node_id, address, token)| {
10571057
let lsps2_client_config = Some(LSPS2ClientConfig {});
10581058
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
10591059
let liquidity_manager = Arc::new(LiquidityManager::new(
@@ -1065,8 +1065,8 @@ fn build_with_store_internal(
10651065
liquidity_client_config,
10661066
));
10671067
Arc::new(LiquiditySource::new_lsps2(
1068-
address.clone(),
10691068
*node_id,
1069+
address.clone(),
10701070
token.clone(),
10711071
Arc::clone(&channel_manager),
10721072
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: Logger,
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)