Skip to content

Commit b341f5f

Browse files
committed
Use inline format args on an oft-repeated string
In e2a05a4 we started ignoring clippy's `uninlined-format-args`, but that doesn't mean that clippy is wrong. Here we take the opportunity while doing cleanups to search+replace a common string in `channelmanager.rs` which could use inlined format arguments. This is the result of running the following replacement: s/Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id/Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"/
1 parent f0119ab commit b341f5f

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4066,7 +4066,7 @@ where
40664066
let per_peer_state = self.per_peer_state.read().unwrap();
40674067

40684068
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
4069-
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) })?;
4069+
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}") })?;
40704070

40714071
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
40724072
let peer_state = &mut *peer_state_lock;
@@ -4464,7 +4464,7 @@ where
44644464
let per_peer_state = self.per_peer_state.read().unwrap();
44654465

44664466
let peer_state_mutex = match per_peer_state.get(counterparty_node_id)
4467-
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) }) {
4467+
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}") }) {
44684468
Ok(p) => p,
44694469
Err(e) => return Err(e),
44704470
};
@@ -5570,7 +5570,7 @@ where
55705570
) -> Result<(), APIError> {
55715571
let per_peer_state = self.per_peer_state.read().unwrap();
55725572
let peer_state_mutex = per_peer_state.get(&counterparty_node_id)
5573-
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) })?;
5573+
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}") })?;
55745574

55755575
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
55765576
let peer_state = &mut *peer_state_lock;
@@ -5928,7 +5928,7 @@ where
59285928
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
59295929
let per_peer_state = self.per_peer_state.read().unwrap();
59305930
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
5931-
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id) })?;
5931+
.ok_or_else(|| APIError::ChannelUnavailable { err: format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}") })?;
59325932
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
59335933
let peer_state = &mut *peer_state_lock;
59345934

@@ -9010,7 +9010,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
90109010
let per_peer_state = self.per_peer_state.read().unwrap();
90119011
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
90129012
.ok_or_else(|| {
9013-
let err_str = format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id);
9013+
let err_str = format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}");
90149014
log_error!(logger, "{}", err_str);
90159015

90169016
APIError::ChannelUnavailable { err: err_str }
@@ -9236,7 +9236,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
92369236
.ok_or_else(|| {
92379237
debug_assert!(false);
92389238
MsgHandleErrInternal::send_err_msg_no_close(
9239-
format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id),
9239+
format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"),
92409240
common_fields.temporary_channel_id)
92419241
})?;
92429242
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -9364,7 +9364,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
93649364
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
93659365
.ok_or_else(|| {
93669366
debug_assert!(false);
9367-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.common_fields.temporary_channel_id)
9367+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.common_fields.temporary_channel_id)
93689368
})?;
93699369
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
93709370
let peer_state = &mut *peer_state_lock;
@@ -9402,7 +9402,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
94029402
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
94039403
.ok_or_else(|| {
94049404
debug_assert!(false);
9405-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.temporary_channel_id)
9405+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.temporary_channel_id)
94069406
})?;
94079407

94089408
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -9520,7 +9520,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
95209520
let peer_state_mutex = per_peer_state.get(&counterparty_node_id)
95219521
.ok_or_else(|| {
95229522
debug_assert!(false);
9523-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), ChannelId([0; 32]))
9523+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), ChannelId([0; 32]))
95249524
})?;
95259525

95269526
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -9557,7 +9557,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
95579557
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
95589558
.ok_or_else(|| {
95599559
debug_assert!(false);
9560-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
9560+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
95619561
})?;
95629562

95639563
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -9601,7 +9601,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
96019601
.ok_or_else(|| {
96029602
debug_assert!(false);
96039603
MsgHandleErrInternal::send_err_msg_no_close(
9604-
format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id),
9604+
format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"),
96059605
channel_id)
96069606
})?;
96079607
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -9695,7 +9695,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
96959695
.ok_or_else(|| {
96969696
debug_assert!(false);
96979697
MsgHandleErrInternal::send_err_msg_no_close(
9698-
format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id),
9698+
format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"),
96999699
msg.channel_id)
97009700
})?;
97019701
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -9753,7 +9753,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
97539753
.ok_or_else(|| {
97549754
debug_assert!(false);
97559755
MsgHandleErrInternal::send_err_msg_no_close(
9756-
format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id),
9756+
format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"),
97579757
msg.channel_id)
97589758
})?;
97599759
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -9801,7 +9801,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
98019801
.ok_or_else(|| {
98029802
debug_assert!(false);
98039803
MsgHandleErrInternal::send_err_msg_no_close(
9804-
format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id),
9804+
format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"),
98059805
msg.channel_id)
98069806
})?;
98079807
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -9864,7 +9864,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
98649864
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
98659865
.ok_or_else(|| {
98669866
debug_assert!(false);
9867-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
9867+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
98689868
})?;
98699869
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
98709870
let peer_state = &mut *peer_state_lock;
@@ -10098,7 +10098,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1009810098
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1009910099
.ok_or_else(|| {
1010010100
debug_assert!(false);
10101-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
10101+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
1010210102
})?;
1010310103
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1010410104
let peer_state = &mut *peer_state_lock;
@@ -10191,7 +10191,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1019110191
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1019210192
.ok_or_else(|| {
1019310193
debug_assert!(false);
10194-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
10194+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
1019510195
})?;
1019610196
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1019710197
let peer_state = &mut *peer_state_lock;
@@ -10217,7 +10217,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1021710217
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1021810218
.ok_or_else(|| {
1021910219
debug_assert!(false);
10220-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
10220+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
1022110221
})?;
1022210222
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1022310223
let peer_state = &mut *peer_state_lock;
@@ -10246,7 +10246,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1024610246
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1024710247
.ok_or_else(|| {
1024810248
debug_assert!(false);
10249-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
10249+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
1025010250
})?;
1025110251
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1025210252
let peer_state = &mut *peer_state_lock;
@@ -10290,7 +10290,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1029010290
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1029110291
.ok_or_else(|| {
1029210292
debug_assert!(false);
10293-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), channel_id)
10293+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), channel_id)
1029410294
})?;
1029510295
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1029610296
let peer_state = &mut *peer_state_lock;
@@ -10535,7 +10535,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1053510535
let mut peer_state_lock = per_peer_state.get(counterparty_node_id)
1053610536
.ok_or_else(|| {
1053710537
debug_assert!(false);
10538-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
10538+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
1053910539
}).map(|mtx| mtx.lock().unwrap())?;
1054010540
let peer_state = &mut *peer_state_lock;
1054110541
match peer_state.channel_by_id.entry(msg.channel_id) {
@@ -10575,7 +10575,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1057510575
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1057610576
.ok_or_else(|| {
1057710577
debug_assert!(false);
10578-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
10578+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
1057910579
})?;
1058010580
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1058110581
let peer_state = &mut *peer_state_lock;
@@ -10600,7 +10600,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1060010600
let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
1060110601
debug_assert!(false);
1060210602
MsgHandleErrInternal::send_err_msg_no_close(
10603-
format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id),
10603+
format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"),
1060410604
msg.channel_id
1060510605
)
1060610606
})?;
@@ -10653,7 +10653,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1065310653
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1065410654
.ok_or_else(|| {
1065510655
debug_assert!(false);
10656-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
10656+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
1065710657
})?;
1065810658
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1065910659
let peer_state = &mut *peer_state_lock;
@@ -10745,7 +10745,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1074510745
.ok_or_else(|| {
1074610746
debug_assert!(false);
1074710747
MsgHandleErrInternal::send_err_msg_no_close(
10748-
format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id),
10748+
format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"),
1074910749
msg.channel_id
1075010750
)
1075110751
})?;
@@ -10845,7 +10845,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1084510845
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1084610846
.ok_or_else(|| {
1084710847
debug_assert!(false);
10848-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
10848+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
1084910849
})?;
1085010850
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1085110851
let peer_state = &mut *peer_state_lock;
@@ -10885,7 +10885,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1088510885
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1088610886
.ok_or_else(|| {
1088710887
debug_assert!(false);
10888-
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id), msg.channel_id)
10888+
MsgHandleErrInternal::send_err_msg_no_close(format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}"), msg.channel_id)
1088910889
})?;
1089010890
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
1089110891
let peer_state = &mut *peer_state_lock;
@@ -11413,7 +11413,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1141311413
let peer_state_mutex_opt = per_peer_state.get(counterparty_node_id);
1141411414
if peer_state_mutex_opt.is_none() {
1141511415
result = Err(APIError::ChannelUnavailable {
11416-
err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id)
11416+
err: format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}")
1141711417
});
1141811418
return notify;
1141911419
}
@@ -11467,7 +11467,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1146711467
let per_peer_state = self.per_peer_state.read().unwrap();
1146811468
let peer_state_mutex = per_peer_state.get(counterparty_node_id)
1146911469
.ok_or_else(|| APIError::ChannelUnavailable {
11470-
err: format!("Can't find a peer matching the passed counterparty node_id {}", counterparty_node_id)
11470+
err: format!("Can't find a peer matching the passed counterparty node_id {counterparty_node_id}")
1147111471
})?;
1147211472
let mut peer_state = peer_state_mutex.lock().unwrap();
1147311473
let initiator = match peer_state.channel_by_id.entry(*channel_id) {

0 commit comments

Comments
 (0)