Skip to content

Commit feda4b4

Browse files
committed
Take all PublicKey and SocketAddr by value
They are copied/defereneced in most cases anyways, and this makes the interface a bit more uniform.
1 parent f057b31 commit feda4b4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/lib.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,8 @@ impl Node {
844844
}
845845

846846
/// Returns our own listening address.
847-
pub fn listening_address(&self) -> Option<&SocketAddr> {
848-
self.config.listening_address.as_ref()
847+
pub fn listening_address(&self) -> Option<SocketAddr> {
848+
self.config.listening_address
849849
}
850850

851851
/// Retrieve a new on-chain/funding address.
@@ -939,7 +939,7 @@ impl Node {
939939
///
940940
/// Will also remove the peer from the peer store, i.e., after this has been called we won't
941941
/// try to reconnect on restart.
942-
pub fn disconnect(&self, counterparty_node_id: &PublicKey) -> Result<(), Error> {
942+
pub fn disconnect(&self, counterparty_node_id: PublicKey) -> Result<(), Error> {
943943
let rt_lock = self.runtime.read().unwrap();
944944
if rt_lock.is_none() {
945945
return Err(Error::NotRunning);
@@ -954,7 +954,7 @@ impl Node {
954954
}
955955
}
956956

957-
self.peer_manager.disconnect_by_node_id(*counterparty_node_id);
957+
self.peer_manager.disconnect_by_node_id(counterparty_node_id);
958958
Ok(())
959959
}
960960

@@ -1112,10 +1112,10 @@ impl Node {
11121112

11131113
/// Close a previously opened channel.
11141114
pub fn close_channel(
1115-
&self, channel_id: &[u8; 32], counterparty_node_id: &PublicKey,
1115+
&self, channel_id: &[u8; 32], counterparty_node_id: PublicKey,
11161116
) -> Result<(), Error> {
1117-
self.peer_store.remove_peer(counterparty_node_id)?;
1118-
match self.channel_manager.close_channel(channel_id, counterparty_node_id) {
1117+
self.peer_store.remove_peer(&counterparty_node_id)?;
1118+
match self.channel_manager.close_channel(channel_id, &counterparty_node_id) {
11191119
Ok(_) => Ok(()),
11201120
Err(_) => Err(Error::ChannelClosingFailed),
11211121
}
@@ -1277,7 +1277,7 @@ impl Node {
12771277

12781278
/// Send a spontaneous, aka. "keysend", payment
12791279
pub fn send_spontaneous_payment(
1280-
&self, amount_msat: u64, node_id: &PublicKey,
1280+
&self, amount_msat: u64, node_id: PublicKey,
12811281
) -> Result<PaymentHash, Error> {
12821282
let rt_lock = self.runtime.read().unwrap();
12831283
if rt_lock.is_none() {
@@ -1289,7 +1289,7 @@ impl Node {
12891289

12901290
let route_params = RouteParameters {
12911291
payment_params: PaymentParameters::from_node_id(
1292-
*node_id,
1292+
node_id,
12931293
self.config.default_cltv_expiry_delta,
12941294
),
12951295
final_value_msat: amount_msat,

src/test/functional_tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn channel_full_cycle() {
3939
node_a
4040
.connect_open_channel(
4141
node_b.node_id(),
42-
*node_b.listening_address().unwrap(),
42+
node_b.listening_address().unwrap(),
4343
funding_amount_sat,
4444
Some(push_msat),
4545
true,
@@ -180,7 +180,7 @@ fn channel_full_cycle() {
180180
assert_eq!(node_b.payment(&payment_hash).unwrap().direction, PaymentDirection::Inbound);
181181
assert_eq!(node_b.payment(&payment_hash).unwrap().amount_msat, Some(determined_amount_msat));
182182

183-
node_b.close_channel(&channel_id, &node_a.node_id()).unwrap();
183+
node_b.close_channel(&channel_id, node_a.node_id()).unwrap();
184184
expect_event!(node_a, ChannelClosed);
185185
expect_event!(node_b, ChannelClosed);
186186

@@ -240,7 +240,7 @@ fn channel_open_fails_when_funds_insufficient() {
240240
Err(Error::InsufficientFunds),
241241
node_a.connect_open_channel(
242242
node_b.node_id(),
243-
*node_b.listening_address().unwrap(),
243+
node_b.listening_address().unwrap(),
244244
120000,
245245
None,
246246
true

0 commit comments

Comments
 (0)