Skip to content

Commit 8189283

Browse files
committed
Clean up tautologies in ChannelContext::build_commitment_transaction
There is no need for an if statement if it will always be true.
1 parent 9a5e774 commit 8189283

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lightning/src/ln/channel.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3552,13 +3552,9 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
35523552
} else {
35533553
log_trace!(logger, " ...not including inbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, &htlc.payment_hash, htlc.amount_msat, state_name);
35543554
match &htlc.state {
3555-
&InboundHTLCState::LocalRemoved(ref reason) => {
3556-
if generated_by_local {
3557-
if let &InboundHTLCRemovalReason::Fulfill(preimage) = reason {
3558-
inbound_htlc_preimages.push(preimage);
3559-
value_to_self_msat_offset += htlc.amount_msat as i64;
3560-
}
3561-
}
3555+
&InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(preimage)) => {
3556+
inbound_htlc_preimages.push(preimage);
3557+
value_to_self_msat_offset += htlc.amount_msat as i64;
35623558
},
35633559
_ => {},
35643560
}
@@ -3594,13 +3590,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
35943590
} else {
35953591
log_trace!(logger, " ...not including outbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, &htlc.payment_hash, htlc.amount_msat, state_name);
35963592
match htlc.state {
3597-
OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_))|OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_)) => {
3598-
value_to_self_msat_offset -= htlc.amount_msat as i64;
3599-
},
3593+
OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_)) |
3594+
OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_)) |
36003595
OutboundHTLCState::RemoteRemoved(OutboundHTLCOutcome::Success(_)) => {
3601-
if !generated_by_local {
3602-
value_to_self_msat_offset -= htlc.amount_msat as i64;
3603-
}
3596+
value_to_self_msat_offset -= htlc.amount_msat as i64;
36043597
},
36053598
_ => {},
36063599
}

0 commit comments

Comments
 (0)