From 52c2240401d94bd37ac6fac6adf572b77b8e1b29 Mon Sep 17 00:00:00 2001 From: Benno Zeeman Date: Wed, 8 Jan 2025 08:06:51 +0100 Subject: [PATCH] refactor(autonomi): rename record_count to _paid --- ant-cli/src/commands/file.rs | 4 ++-- ant-cli/src/commands/register.rs | 2 +- ant-cli/src/utils.rs | 6 +++--- autonomi/src/client/data/mod.rs | 4 ++-- autonomi/src/client/data/public.rs | 2 +- autonomi/src/client/graph.rs | 2 +- autonomi/src/client/mod.rs | 2 +- autonomi/src/client/registers.rs | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ant-cli/src/commands/file.rs b/ant-cli/src/commands/file.rs index 8db5acf5ab..412d4879be 100644 --- a/ant-cli/src/commands/file.rs +++ b/ant-cli/src/commands/file.rs @@ -76,13 +76,13 @@ pub async fn upload(file: &str, public: bool, peers: Vec) -> 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 diff --git a/ant-cli/src/commands/register.rs b/ant-cli/src/commands/register.rs index 5598fc0544..ce840c28ff 100644 --- a/ant-cli/src/commands/register.rs +++ b/ant-cli/src/commands/register.rs @@ -99,7 +99,7 @@ pub async fn create(name: &str, value: &str, public: bool, peers: Vec } 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 { diff --git a/ant-cli/src/utils.rs b/ant-cli/src/utils.rs index 81b1d1e36f..19f02878f9 100644 --- a/ant-cli/src/utils.rs +++ b/ant-cli/src/utils.rs @@ -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, @@ -43,7 +43,7 @@ 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; } } @@ -51,7 +51,7 @@ pub fn collect_upload_summary( UploadSummary { tokens_spent, - record_count, + records_paid: record_count, records_already_paid, } }); diff --git a/autonomi/src/client/data/mod.rs b/autonomi/src/client/data/mod.rs index 5efa9c9807..5fc1eb3290 100644 --- a/autonomi/src/client/data/mod.rs +++ b/autonomi/src/client/data/mod.rs @@ -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() { @@ -254,7 +254,7 @@ impl Client { .sum::(); let summary = UploadSummary { - record_count, + records_paid: record_count, records_already_paid: skipped_payments, tokens_spent, }; diff --git a/autonomi/src/client/data/public.rs b/autonomi/src/client/data/public.rs index 0d82e4f08b..8f1da33b26 100644 --- a/autonomi/src/client/data/public.rs +++ b/autonomi/src/client/data/public.rs @@ -97,7 +97,7 @@ impl Client { .sum::(); let summary = UploadSummary { - record_count, + records_paid: record_count, records_already_paid: skipped_payments, tokens_spent, }; diff --git a/autonomi/src/client/graph.rs b/autonomi/src/client/graph.rs index 07cc900d60..7f339b7c0c 100644 --- a/autonomi/src/client/graph.rs +++ b/autonomi/src/client/graph.rs @@ -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(), }; diff --git a/autonomi/src/client/mod.rs b/autonomi/src/client/mod.rs index 750eccfdbb..7245180955 100644 --- a/autonomi/src/client/mod.rs +++ b/autonomi/src/client/mod.rs @@ -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 diff --git a/autonomi/src/client/registers.rs b/autonomi/src/client/registers.rs index ad4bf67197..730af56464 100644 --- a/autonomi/src/client/registers.rs +++ b/autonomi/src/client/registers.rs @@ -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(), };