Skip to content

Commit 22be385

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 728e7c2 commit 22be385

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
@@ -3703,13 +3703,9 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
37033703
} else {
37043704
log_trace!(logger, " ...not including inbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, &htlc.payment_hash, htlc.amount_msat, state_name);
37053705
match &htlc.state {
3706-
&InboundHTLCState::LocalRemoved(ref reason) => {
3707-
if generated_by_local {
3708-
if let &InboundHTLCRemovalReason::Fulfill(preimage) = reason {
3709-
inbound_htlc_preimages.push(preimage);
3710-
value_to_self_msat_offset += htlc.amount_msat as i64;
3711-
}
3712-
}
3706+
&InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(preimage)) => {
3707+
inbound_htlc_preimages.push(preimage);
3708+
value_to_self_msat_offset += htlc.amount_msat as i64;
37133709
},
37143710
_ => {},
37153711
}
@@ -3745,13 +3741,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
37453741
} else {
37463742
log_trace!(logger, " ...not including outbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, &htlc.payment_hash, htlc.amount_msat, state_name);
37473743
match htlc.state {
3748-
OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_))|OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_)) => {
3749-
value_to_self_msat_offset -= htlc.amount_msat as i64;
3750-
},
3744+
OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_)) |
3745+
OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_)) |
37513746
OutboundHTLCState::RemoteRemoved(OutboundHTLCOutcome::Success(_)) => {
3752-
if !generated_by_local {
3753-
value_to_self_msat_offset -= htlc.amount_msat as i64;
3754-
}
3747+
value_to_self_msat_offset -= htlc.amount_msat as i64;
37553748
},
37563749
_ => {},
37573750
}

0 commit comments

Comments
 (0)