diff --git a/sn_cli/src/subcommands/files.rs b/sn_cli/src/subcommands/files.rs index 766b957f2a..673aa7c815 100644 --- a/sn_cli/src/subcommands/files.rs +++ b/sn_cli/src/subcommands/files.rs @@ -247,7 +247,7 @@ async fn upload_files( for chunks_batch in chunks_to_upload.chunks(batch_size) { // pay for and verify payment... if we don't verify here, chunks uploads will surely fail let (cost, new_balance) = match file_api - .pay_for_chunks(chunks_batch.iter().map(|(name, _)| *name).collect(), true) + .pay_for_chunks(chunks_batch.iter().map(|(name, _)| *name).collect()) .await { Ok((cost, new_balance)) => (cost, new_balance), @@ -481,7 +481,6 @@ async fn verify_and_repay_if_needed( failed_chunks_batch .iter() .map(|(addr, _path)| sn_protocol::NetworkAddress::ChunkAddress(*addr)), - true, ) .await .wrap_err("Failed to repay for record storage for {failed_chunks_batch:?}.")?; diff --git a/sn_cli/src/subcommands/wallet.rs b/sn_cli/src/subcommands/wallet.rs index d99bb4d2c0..8c194b669e 100644 --- a/sn_cli/src/subcommands/wallet.rs +++ b/sn_cli/src/subcommands/wallet.rs @@ -158,8 +158,7 @@ pub(crate) async fn wallet_cmds( .map(|(n, _)| *n) .collect(); - // pay for and verify payment... if we don't verify here, chunks uploads will surely fail - file_api.pay_for_chunks(all_chunks, verify_store).await?; + file_api.pay_for_chunks(all_chunks).await?; } cmd => { return Err(eyre!( diff --git a/sn_client/src/file_apis.rs b/sn_client/src/file_apis.rs index df6d1d7340..eeb02d64de 100644 --- a/sn_client/src/file_apis.rs +++ b/sn_client/src/file_apis.rs @@ -189,22 +189,16 @@ impl Files { /// Pay for a given set of chunks. /// /// Returns the cost and the resulting new balance of the local wallet. - pub async fn pay_for_chunks( - &self, - chunks: Vec, - verify_store: bool, - ) -> Result<(NanoTokens, NanoTokens)> { + pub async fn pay_for_chunks(&self, chunks: Vec) -> Result<(NanoTokens, NanoTokens)> { let mut wallet_client = self.wallet()?; info!("Paying for and uploading {:?} chunks", chunks.len()); - let cost = wallet_client - .pay_for_storage( - chunks.iter().map(|name| { + let cost = + wallet_client + .pay_for_storage(chunks.iter().map(|name| { sn_protocol::NetworkAddress::ChunkAddress(ChunkAddress::new(*name)) - }), - verify_store, - ) - .await?; + })) + .await?; wallet_client.store_local_wallet()?; let new_balance = wallet_client.balance(); @@ -296,7 +290,6 @@ impl Files { chunks .iter() .map(|(name, _)| NetworkAddress::ChunkAddress(ChunkAddress::new(*name))), - true, ) .await .expect("Failed to pay for storage for new file at {file_addr:?}"); @@ -317,12 +310,9 @@ impl Files { // Now we pay again or top up, depending on the new current store cost is let new_cost = self .wallet()? - .pay_for_storage( - failed_chunks.iter().map(|(addr, _path)| { - sn_protocol::NetworkAddress::ChunkAddress(ChunkAddress::new(*addr)) - }), - true, - ) + .pay_for_storage(failed_chunks.iter().map(|(addr, _path)| { + sn_protocol::NetworkAddress::ChunkAddress(ChunkAddress::new(*addr)) + })) .await?; cost = cost.checked_add(new_cost).ok_or(Error::Transfers( diff --git a/sn_client/src/register.rs b/sn_client/src/register.rs index 924857d2eb..aec004eea2 100644 --- a/sn_client/src/register.rs +++ b/sn_client/src/register.rs @@ -204,7 +204,7 @@ impl ClientRegister { let net_addr = sn_protocol::NetworkAddress::RegisterAddress(addr); // Let's make the storage payment cost = wallet_client - .pay_for_storage(std::iter::once(net_addr.clone()), true) + .pay_for_storage(std::iter::once(net_addr.clone())) .await?; println!("Successfully made payment of {cost} for a Register (At a cost per record of {cost:?}.)"); diff --git a/sn_client/src/wallet.rs b/sn_client/src/wallet.rs index 4c6e5a78c5..622a4e6233 100644 --- a/sn_client/src/wallet.rs +++ b/sn_client/src/wallet.rs @@ -137,8 +137,8 @@ impl WalletClient { pub async fn pay_for_storage( &mut self, content_addrs: impl Iterator, - verify_store: bool, ) -> WalletResult { + let verify_store = true; let mut total_cost = NanoTokens::zero(); let mut payment_map = BTreeMap::default(); diff --git a/sn_node/tests/storage_payments.rs b/sn_node/tests/storage_payments.rs index ddcd44f890..12553800df 100644 --- a/sn_node/tests/storage_payments.rs +++ b/sn_node/tests/storage_payments.rs @@ -50,7 +50,7 @@ async fn storage_payment_succeeds() -> Result<()> { ); let _cost = wallet_client - .pay_for_storage(random_content_addrs.clone().into_iter(), true) + .pay_for_storage(random_content_addrs.clone().into_iter()) .await?; println!("Verifying balance has been paid from the wallet..."); @@ -90,7 +90,6 @@ async fn storage_payment_fails_with_insufficient_money() -> Result<()> { .into_iter() .take(subset_len) .map(|(name, _)| NetworkAddress::ChunkAddress(ChunkAddress::new(name))), - true, ) .await?; @@ -131,10 +130,7 @@ async fn storage_payment_proofs_cached_in_wallet() -> Result<()> { let subset_len = random_content_addrs.len() / 3; println!("Paying for {subset_len} random addresses...",); let storage_cost = wallet_client - .pay_for_storage( - random_content_addrs.clone().into_iter().take(subset_len), - true, - ) + .pay_for_storage(random_content_addrs.clone().into_iter().take(subset_len)) .await?; // check we've paid only for the subset of addresses, 1 nano per addr @@ -154,7 +150,7 @@ async fn storage_payment_proofs_cached_in_wallet() -> Result<()> { // now let's request to pay for all addresses, even that we've already paid for a subset of them let mut wallet_client = WalletClient::new(client.clone(), paying_wallet); let storage_cost = wallet_client - .pay_for_storage(random_content_addrs.clone().into_iter(), false) + .pay_for_storage(random_content_addrs.clone().into_iter()) .await?; // check we've paid only for addresses we haven't previously paid for, 1 nano per addr @@ -198,7 +194,6 @@ async fn storage_payment_chunk_upload_succeeds() -> Result<()> { chunks .iter() .map(|(name, _)| NetworkAddress::ChunkAddress(ChunkAddress::new(*name))), - true, ) .await?; @@ -288,7 +283,7 @@ async fn storage_payment_register_creation_succeeds() -> Result<()> { let net_addr = NetworkAddress::from_register_address(address); let _cost = wallet_client - .pay_for_storage(std::iter::once(net_addr), true) + .pay_for_storage(std::iter::once(net_addr)) .await?; let (mut register, _cost) = client diff --git a/sn_node/tests/verify_data_location.rs b/sn_node/tests/verify_data_location.rs index 5e71a2d602..39371cd8c2 100644 --- a/sn_node/tests/verify_data_location.rs +++ b/sn_node/tests/verify_data_location.rs @@ -343,7 +343,6 @@ async fn store_chunks( chunks .iter() .map(|(name, _)| NetworkAddress::ChunkAddress(ChunkAddress::new(*name))), - true, ) .await .expect("Failed to pay for storage for new file at {file_addr:?}");