Skip to content

Commit

Permalink
cleanup send payment errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Jan 7, 2025
1 parent 68a7b00 commit ad22023
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/fiber/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ where
payment_data.payment_hash, e
);
self.set_payment_fail_with_error(payment_session, &err);
return Err(Error::SendPaymentError(err));
return Err(Error::SendPaymentFirstHopError(err, false));
}
};

Expand Down Expand Up @@ -1747,7 +1747,8 @@ where
.await
{
Ok(payment_session) => return Ok(payment_session),
Err(Error::SendPaymentFirstHopError(err, need_retry)) => {
Err(err) => {
let need_retry = matches!(err, Error::SendPaymentFirstHopError(_, true));
if need_retry {
// If this is the first hop error, like the WaitingTlcAck error,
// we will just retry later, return Ok here for letting endpoint user
Expand All @@ -1759,22 +1760,9 @@ where
});
return Ok(payment_session);
} else {
return Err(Error::SendPaymentError(err));
return Err(err);
}
}
Err(e) => {
// we will retry the payment session,
// but we need to retry later to let the actor to process failure,
// so that we can make different choice for later try
let payment_hash = payment_data.payment_hash;
myself.send_after(Duration::from_millis(500), move || {
NetworkActorMessage::new_event(NetworkActorEvent::RetrySendPayment(
payment_hash,
))
});
debug!("send payment error: {:?}", e);
return Err(e);
}
}
} else {
let error = payment_session.last_error.clone().unwrap_or_else(|| {
Expand Down

0 comments on commit ad22023

Please sign in to comment.