Skip to content

Commit

Permalink
chore(uploader): return the list of max repayment reached items
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin authored and maqi committed May 23, 2024
1 parent 20aa48c commit ca4663f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions sn_client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ pub enum Error {
#[error("Too many sequential payment errors reported during upload")]
SequentialUploadPaymentError,

#[error("The maximum specified repayments has been reached")]
MaximumRepaymentsReached,
#[error("The maximum specified repayments has been reached for {0:?}")]
MaximumRepaymentsReached(Vec<XorName>),

#[error("Error occurred when access wallet file")]
FailedToAccessWallet,
Expand Down
2 changes: 1 addition & 1 deletion sn_client/src/uploader/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ async fn maximum_repayment_error_should_be_triggered_during_get_store_cost() ->

assert_matches!(
upload_handle.await?,
Err(ClientError::MaximumRepaymentsReached)
Err(ClientError::MaximumRepaymentsReached(_))
);
let events = events_handle.await?;

Expand Down
8 changes: 5 additions & 3 deletions sn_client/src/uploader/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ pub(super) async fn start_upload(
"The maximum repayments were reached for these addresses: {:?}",
uploader.max_repayments_reached
);
return Err(ClientError::MaximumRepaymentsReached);
return Err(ClientError::MaximumRepaymentsReached(
uploader.max_repayments_reached.into_iter().collect(),
));
}

let summary = UploadSummary {
Expand Down Expand Up @@ -535,7 +537,7 @@ impl UploaderInterface for Uploader {
error!("Encountered error {err:?} when getting store_cost for {xorname:?}",);

let max_repayments_reached =
matches!(&err, ClientError::MaximumRepaymentsReached);
matches!(&err, ClientError::MaximumRepaymentsReached(_));

TaskResult::GetStoreCostErr {
xorname,
Expand Down Expand Up @@ -940,7 +942,7 @@ impl InnerUploader {
max_repayments_for_failed_data,
) {
// error is used by the caller.
return Err(ClientError::MaximumRepaymentsReached);
return Err(ClientError::MaximumRepaymentsReached(vec![xorname]));
}

debug!("Filtering out payments from {filter_list:?} during get_store_cost for {xorname:?}");
Expand Down

0 comments on commit ca4663f

Please sign in to comment.