diff --git a/bindings/core/src/method_handler/client.rs b/bindings/core/src/method_handler/client.rs index 53f65631cd..3836ede83b 100644 --- a/bindings/core/src/method_handler/client.rs +++ b/bindings/core/src/method_handler/client.rs @@ -260,7 +260,7 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM ClientMethod::GetOutputsIgnoreErrors { output_ids } => { let outputs_response = client .get_outputs_with_metadata_ignore_errors(&output_ids) - .await? + .await .iter() .map(OutputWithMetadataResponse::from) .collect(); diff --git a/sdk/src/client/node_api/core/mod.rs b/sdk/src/client/node_api/core/mod.rs index ade26cf22a..5215a5e65d 100644 --- a/sdk/src/client/node_api/core/mod.rs +++ b/sdk/src/client/node_api/core/mod.rs @@ -33,14 +33,12 @@ impl Client { /// Requests outputs by their output ID in parallel, ignoring failed requests. /// Useful to get data about spent outputs, that might not be pruned yet. - pub async fn get_outputs_ignore_errors(&self, output_ids: &[OutputId]) -> Result> { - Ok( - futures::future::join_all(output_ids.iter().map(|id| self.get_output(id))) - .await - .into_iter() - .filter_map(Result::ok) - .collect(), - ) + pub async fn get_outputs_ignore_errors(&self, output_ids: &[OutputId]) -> Vec { + futures::future::join_all(output_ids.iter().map(|id| self.get_output(id))) + .await + .into_iter() + .filter_map(Result::ok) + .collect() } /// Requests metadata for outputs by their output ID in parallel. @@ -49,14 +47,12 @@ impl Client { } /// Requests metadata for outputs by their output ID in parallel, ignoring failed requests. - pub async fn get_outputs_metadata_ignore_errors(&self, output_ids: &[OutputId]) -> Result> { - Ok( - futures::future::join_all(output_ids.iter().map(|id| self.get_output_metadata(id))) - .await - .into_iter() - .filter_map(Result::ok) - .collect(), - ) + pub async fn get_outputs_metadata_ignore_errors(&self, output_ids: &[OutputId]) -> Vec { + futures::future::join_all(output_ids.iter().map(|id| self.get_output_metadata(id))) + .await + .into_iter() + .filter_map(Result::ok) + .collect() } /// Requests outputs and their metadata by their output ID in parallel. @@ -66,16 +62,11 @@ impl Client { /// Requests outputs and their metadata by their output ID in parallel, ignoring failed requests. /// Useful to get data about spent outputs, that might not be pruned yet. - pub async fn get_outputs_with_metadata_ignore_errors( - &self, - output_ids: &[OutputId], - ) -> Result> { - Ok( - futures::future::join_all(output_ids.iter().map(|id| self.get_output_with_metadata(id))) - .await - .into_iter() - .filter_map(Result::ok) - .collect(), - ) + pub async fn get_outputs_with_metadata_ignore_errors(&self, output_ids: &[OutputId]) -> Vec { + futures::future::join_all(output_ids.iter().map(|id| self.get_output_with_metadata(id))) + .await + .into_iter() + .filter_map(Result::ok) + .collect() } } diff --git a/sdk/src/wallet/operations/syncing/mod.rs b/sdk/src/wallet/operations/syncing/mod.rs index abbbbb4d4e..55366eefa3 100644 --- a/sdk/src/wallet/operations/syncing/mod.rs +++ b/sdk/src/wallet/operations/syncing/mod.rs @@ -61,6 +61,7 @@ where let time_now = crate::client::unix_timestamp_now().as_millis(); let mut last_synced = self.last_synced.lock().await; log::debug!("[SYNC] last time synced before {}ms", time_now - *last_synced); + if !options.force_syncing && time_now - *last_synced < MIN_SYNC_INTERVAL { log::debug!( "[SYNC] synced within the latest {} ms, only calculating balance", @@ -88,7 +89,9 @@ where // Update last_synced mutex let time_now = crate::client::unix_timestamp_now().as_millis(); *last_synced = time_now; + log::debug!("[SYNC] finished syncing in {:.2?}", syc_start_time.elapsed()); + Ok(balance) } @@ -120,7 +123,7 @@ where let spent_or_unsynced_output_metadata_responses = self .client() .get_outputs_metadata_ignore_errors(&spent_or_not_synced_output_ids) - .await?; + .await; // Add the output response to the output ids, the output response is optional, because an output could be // pruned and then we can't get the metadata diff --git a/sdk/src/wallet/operations/syncing/outputs.rs b/sdk/src/wallet/operations/syncing/outputs.rs index 85461ce33d..153da4f9a3 100644 --- a/sdk/src/wallet/operations/syncing/outputs.rs +++ b/sdk/src/wallet/operations/syncing/outputs.rs @@ -151,8 +151,7 @@ where basic_block_body.payload() { let inputs_with_meta = - get_inputs_for_transaction_payload(&client, transaction_payload) - .await?; + get_inputs_for_transaction_payload(&client, transaction_payload).await; let inputs_response: Vec = inputs_with_meta .into_iter() .map(OutputWithMetadataResponse::from) @@ -210,7 +209,7 @@ where pub(crate) async fn get_inputs_for_transaction_payload( client: &Client, transaction_payload: &SignedTransactionPayload, -) -> crate::wallet::Result> { +) -> Vec { let output_ids = transaction_payload .transaction() .inputs() @@ -221,8 +220,5 @@ pub(crate) async fn get_inputs_for_transaction_payload( }) .collect::>(); - client - .get_outputs_with_metadata_ignore_errors(&output_ids) - .await - .map_err(|e| e.into()) + client.get_outputs_with_metadata_ignore_errors(&output_ids).await }