Skip to content

Commit a317442

Browse files
committed
f - DRY
1 parent 6fff756 commit a317442

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

lightning/src/ln/channel.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7274,13 +7274,15 @@ where
72747274

72757275
#[cfg(any(test, fuzzing))]
72767276
{
7277-
*self.funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None;
7278-
*self.funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
7279-
if let Some(pending_splice) = self.pending_splice.as_mut() {
7280-
for funding in pending_splice.pending_funding.iter_mut() {
7281-
*funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None;
7282-
*funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
7283-
}
7277+
for funding in core::iter::once(&mut self.funding).chain(
7278+
self.pending_splice
7279+
.as_mut()
7280+
.map(|pending_splice| pending_splice.pending_funding.as_mut_slice())
7281+
.unwrap_or(&mut [])
7282+
.iter_mut(),
7283+
) {
7284+
*funding.next_local_commitment_tx_fee_info_cached.lock().unwrap() = None;
7285+
*funding.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
72847286
}
72857287
}
72867288

@@ -7481,13 +7483,15 @@ where
74817483
}
74827484
}
74837485

7484-
self.funding.value_to_self_msat =
7485-
(self.funding.value_to_self_msat as i64 + value_to_self_msat_diff) as u64;
7486-
if let Some(pending_splice) = self.pending_splice.as_mut() {
7487-
for funding in pending_splice.pending_funding.iter_mut() {
7488-
funding.value_to_self_msat =
7489-
(funding.value_to_self_msat as i64 + value_to_self_msat_diff) as u64;
7490-
}
7486+
for funding in core::iter::once(&mut self.funding).chain(
7487+
self.pending_splice
7488+
.as_mut()
7489+
.map(|pending_splice| pending_splice.pending_funding.as_mut_slice())
7490+
.unwrap_or(&mut [])
7491+
.iter_mut(),
7492+
) {
7493+
funding.value_to_self_msat =
7494+
(funding.value_to_self_msat as i64 + value_to_self_msat_diff) as u64;
74917495
}
74927496

74937497
if let Some((feerate, update_state)) = self.context.pending_update_fee {

0 commit comments

Comments
 (0)