@@ -4344,7 +4344,7 @@ where
4344
4344
if let Some(ChannelPhase::Funded(ref mut chan)) = peer_state.channel_by_id.get_mut(&forward_chan_id) {
4345
4345
let logger = WithChannelContext::from(&self.logger, &chan.context);
4346
4346
for forward_info in pending_forwards.drain(..) {
4347
- match forward_info {
4347
+ let queue_fail_htlc_res = match forward_info {
4348
4348
HTLCForwardInfo::AddHTLC(PendingAddHTLCInfo {
4349
4349
prev_short_channel_id, prev_htlc_id, prev_funding_outpoint, prev_user_channel_id,
4350
4350
forward_info: PendingHTLCInfo {
@@ -4390,40 +4390,35 @@ where
4390
4390
));
4391
4391
continue;
4392
4392
}
4393
+ None
4393
4394
},
4394
4395
HTLCForwardInfo::AddHTLC { .. } => {
4395
4396
panic!("short_channel_id != 0 should imply any pending_forward entries are of type Forward");
4396
4397
},
4397
4398
HTLCForwardInfo::FailHTLC { htlc_id, err_packet } => {
4398
4399
log_trace!(logger, "Failing HTLC back to channel with short id {} (backward HTLC ID {}) after delay", short_chan_id, htlc_id);
4399
- if let Err(e) = chan.queue_fail_htlc(
4400
- htlc_id, err_packet, &&logger
4401
- ) {
4402
- if let ChannelError::Ignore(msg) = e {
4403
- log_trace!(logger, "Failed to fail HTLC with ID {} backwards to short_id {}: {}", htlc_id, short_chan_id, msg);
4404
- } else {
4405
- panic!("Stated return value requirements in queue_fail_htlc() were not met");
4406
- }
4407
- // fail-backs are best-effort, we probably already have one
4408
- // pending, and if not that's OK, if not, the channel is on
4409
- // the chain and sending the HTLC-Timeout is their problem.
4410
- continue;
4411
- }
4400
+ Some((chan.queue_fail_htlc(htlc_id, err_packet, &&logger), htlc_id))
4412
4401
},
4413
4402
HTLCForwardInfo::FailMalformedHTLC { htlc_id, failure_code, sha256_of_onion } => {
4414
4403
log_trace!(logger, "Failing malformed HTLC back to channel with short id {} (backward HTLC ID {}) after delay", short_chan_id, htlc_id);
4415
- if let Err(e) = chan.queue_fail_malformed_htlc(htlc_id, failure_code, sha256_of_onion, &&logger) {
4416
- if let ChannelError::Ignore(msg) = e {
4417
- log_trace!(logger, "Failed to fail HTLC with ID {} backwards to short_id {}: {}", htlc_id, short_chan_id, msg);
4418
- } else {
4419
- panic!("Stated return value requirements in queue_fail_malformed_htlc() were not met");
4420
- }
4421
- // fail-backs are best-effort, we probably already have one
4422
- // pending, and if not that's OK, if not, the channel is on
4423
- // the chain and sending the HTLC-Timeout is their problem.
4424
- continue;
4425
- }
4404
+ let res = chan.queue_fail_malformed_htlc(
4405
+ htlc_id, failure_code, sha256_of_onion, &&logger
4406
+ );
4407
+ Some((res, htlc_id))
4426
4408
},
4409
+ };
4410
+ if let Some((queue_fail_htlc_res, htlc_id)) = queue_fail_htlc_res {
4411
+ if let Err(e) = queue_fail_htlc_res {
4412
+ if let ChannelError::Ignore(msg) = e {
4413
+ log_trace!(logger, "Failed to fail HTLC with ID {} backwards to short_id {}: {}", htlc_id, short_chan_id, msg);
4414
+ } else {
4415
+ panic!("Stated return value requirements in queue_fail_{{malformed_}}htlc() were not met");
4416
+ }
4417
+ // fail-backs are best-effort, we probably already have one
4418
+ // pending, and if not that's OK, if not, the channel is on
4419
+ // the chain and sending the HTLC-Timeout is their problem.
4420
+ continue;
4421
+ }
4427
4422
}
4428
4423
}
4429
4424
} else {
0 commit comments