Skip to content

Commit ca3fa4e

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 df9a561 commit ca3fa4e

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
@@ -3504,13 +3504,9 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
35043504
} else {
35053505
log_trace!(logger, " ...not including inbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, &htlc.payment_hash, htlc.amount_msat, state_name);
35063506
match &htlc.state {
3507-
&InboundHTLCState::LocalRemoved(ref reason) => {
3508-
if generated_by_local {
3509-
if let &InboundHTLCRemovalReason::Fulfill(preimage) = reason {
3510-
inbound_htlc_preimages.push(preimage);
3511-
value_to_self_msat_offset += htlc.amount_msat as i64;
3512-
}
3513-
}
3507+
&InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(preimage)) => {
3508+
inbound_htlc_preimages.push(preimage);
3509+
value_to_self_msat_offset += htlc.amount_msat as i64;
35143510
},
35153511
_ => {},
35163512
}
@@ -3546,13 +3542,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
35463542
} else {
35473543
log_trace!(logger, " ...not including outbound HTLC {} (hash {}) with value {} due to state ({})", htlc.htlc_id, &htlc.payment_hash, htlc.amount_msat, state_name);
35483544
match htlc.state {
3549-
OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_))|OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_)) => {
3550-
value_to_self_msat_offset -= htlc.amount_msat as i64;
3551-
},
3545+
OutboundHTLCState::AwaitingRemoteRevokeToRemove(OutboundHTLCOutcome::Success(_)) |
3546+
OutboundHTLCState::AwaitingRemovedRemoteRevoke(OutboundHTLCOutcome::Success(_)) |
35523547
OutboundHTLCState::RemoteRemoved(OutboundHTLCOutcome::Success(_)) => {
3553-
if !generated_by_local {
3554-
value_to_self_msat_offset -= htlc.amount_msat as i64;
3555-
}
3548+
value_to_self_msat_offset -= htlc.amount_msat as i64;
35563549
},
35573550
_ => {},
35583551
}

0 commit comments

Comments
 (0)