Skip to content

Commit

Permalink
refactor(autonomi): rename record_count to _paid
Browse files Browse the repository at this point in the history
  • Loading branch information
b-zee committed Jan 8, 2025
1 parent c995d16 commit 52c2240
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions ant-cli/src/commands/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ pub async fn upload(file: &str, public: bool, peers: Vec<Multiaddr>) -> Result<(

// get summary
let summary = upload_summary_thread.await?;
if summary.record_count == 0 {
if summary.records_paid == 0 {
println!("All chunks already exist on the network.");
} else {
println!("Successfully uploaded: {file}");
println!("At address: {local_addr}");
info!("Successfully uploaded: {file} at address: {local_addr}");
println!("Number of chunks uploaded: {}", summary.record_count);
println!("Number of chunks uploaded: {}", summary.records_paid);
println!(
"Number of chunks already paid/uploaded: {}",
summary.records_already_paid
Expand Down
2 changes: 1 addition & 1 deletion ant-cli/src/commands/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub async fn create(name: &str, value: &str, public: bool, peers: Vec<Multiaddr>
}

let summary = upload_summary_thread.await?;
if summary.record_count == 0 {
if summary.records_paid == 0 {
println!("✅ The register already exists on the network at address: {address}.");
println!("No tokens were spent.");
} else {
Expand Down
6 changes: 3 additions & 3 deletions ant-cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn collect_upload_summary(
match event {
Some(ClientEvent::UploadComplete(upload_summary)) => {
tokens_spent += upload_summary.tokens_spent;
record_count += upload_summary.record_count;
record_count += upload_summary.records_paid;
records_already_paid += upload_summary.records_already_paid;
}
None => break,
Expand All @@ -43,15 +43,15 @@ pub fn collect_upload_summary(
match event {
ClientEvent::UploadComplete(upload_summary) => {
tokens_spent += upload_summary.tokens_spent;
record_count += upload_summary.record_count;
record_count += upload_summary.records_paid;
records_already_paid += upload_summary.records_already_paid;
}
}
}

UploadSummary {
tokens_spent,
record_count,
records_paid: record_count,
records_already_paid,
}
});
Expand Down
4 changes: 2 additions & 2 deletions autonomi/src/client/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl Client {
return Err(last_chunk_fail.1);
}

let record_count = chunks.len() - skipped_payments;
let record_count = chunks.len().saturating_sub(skipped_payments);

// Reporting
if let Some(channel) = self.client_event_sender.as_ref() {
Expand All @@ -254,7 +254,7 @@ impl Client {
.sum::<Amount>();

let summary = UploadSummary {
record_count,
records_paid: record_count,
records_already_paid: skipped_payments,
tokens_spent,
};
Expand Down
2 changes: 1 addition & 1 deletion autonomi/src/client/data/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Client {
.sum::<Amount>();

let summary = UploadSummary {
record_count,
records_paid: record_count,
records_already_paid: skipped_payments,
tokens_spent,
};
Expand Down
2 changes: 1 addition & 1 deletion autonomi/src/client/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Client {
// send client event
if let Some(channel) = self.client_event_sender.as_ref() {
let summary = UploadSummary {
record_count: 1usize.saturating_sub(skipped_payments),
records_paid: 1usize.saturating_sub(skipped_payments),
records_already_paid: skipped_payments,
tokens_spent: price.as_atto(),
};
Expand Down
2 changes: 1 addition & 1 deletion autonomi/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ pub enum ClientEvent {
#[derive(Debug, Clone)]
pub struct UploadSummary {
/// Records that were uploaded to the network
pub record_count: usize,
pub records_paid: usize,
/// Records that were already paid for so were not re-uploaded
pub records_already_paid: usize,
/// Total cost of the upload
Expand Down
2 changes: 1 addition & 1 deletion autonomi/src/client/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl Client {

if let Some(channel) = self.client_event_sender.as_ref() {
let summary = UploadSummary {
record_count: 1usize.saturating_sub(skipped_payments),
records_paid: 1usize.saturating_sub(skipped_payments),
records_already_paid: skipped_payments,
tokens_spent: price.as_atto(),
};
Expand Down

0 comments on commit 52c2240

Please sign in to comment.