From ad22023dfb8d360e740ebc7fb7bc6f4be1574ef1 Mon Sep 17 00:00:00 2001 From: yukang Date: Tue, 7 Jan 2025 09:16:10 +0800 Subject: [PATCH] cleanup send payment errors --- src/fiber/network.rs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/fiber/network.rs b/src/fiber/network.rs index b48306b84..591b58481 100644 --- a/src/fiber/network.rs +++ b/src/fiber/network.rs @@ -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)); } }; @@ -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 @@ -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(|| {