Skip to content

Commit

Permalink
Merge pull request #2023 from maqi/upload_un-recoverable_error_during…
Browse files Browse the repository at this point in the history
…_make_payment

fix(node): terminate make_payment process during unrecoverable error
  • Loading branch information
maqi authored Aug 5, 2024
2 parents b4da842 + 492f50d commit 5200a00
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions sn_client/src/uploader/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,8 @@ impl InnerUploader {
.resend_pending_transaction_blocking_loop()
.await;

let mut terminate_process = false;

let result = match wallet_client.pay_for_records(&cost_map, verify_store).await
{
Ok((storage_cost, royalty_fees)) => {
Expand Down Expand Up @@ -897,10 +899,13 @@ impl InnerUploader {
WalletError::Transfer(TransferError::NotEnoughBalance(
available,
required,
)) => TaskResult::MakePaymentsErr {
failed_xornames,
insufficient_balance: Some((available, required)),
},
)) => {
terminate_process = true;
TaskResult::MakePaymentsErr {
failed_xornames,
insufficient_balance: Some((available, required)),
}
}
_ => TaskResult::MakePaymentsErr {
failed_xornames,
insufficient_balance: None,
Expand All @@ -914,6 +919,16 @@ impl InnerUploader {
});

cost_map = BTreeMap::new();

if terminate_process {
// The error will trigger the entire upload process to be terminated.
// Hence here we shall terminate the inner loop first,
// to avoid the wallet going furhter to be potentially got corrupted.
warn!(
"Terminating make payment processing loop due to un-recoverable error."
);
break;
}
}
}
debug!("Make payment processing loop terminated.");
Expand Down

0 comments on commit 5200a00

Please sign in to comment.