From 038b9a6b14538ad13b227ed0da750fcdf42be48a Mon Sep 17 00:00:00 2001 From: Stan Bondi Date: Sun, 21 Nov 2021 13:17:27 +0200 Subject: [PATCH] chore: minor clippy fixes (#3576) Description --- - remove unnecessary vec copy in protobuf conversion - clippy fixes - remove duplicate utility function Motivation and Context --- Fix some minor clippy warnings How Has This Been Tested? --- Existing tests pass --- .../src/conversions/aggregate_body.rs | 2 +- base_layer/core/src/proto/mod.rs | 2 +- base_layer/core/src/proto/transaction.rs | 2 +- base_layer/core/src/proto/utils.rs | 15 --------------- 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/applications/tari_app_grpc/src/conversions/aggregate_body.rs b/applications/tari_app_grpc/src/conversions/aggregate_body.rs index bd8a288800..2b296b96ae 100644 --- a/applications/tari_app_grpc/src/conversions/aggregate_body.rs +++ b/applications/tari_app_grpc/src/conversions/aggregate_body.rs @@ -21,7 +21,7 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use std::convert::TryFrom; -use tari_core::{proto::utils::try_convert_all, transactions::aggregated_body::AggregateBody}; +use tari_core::{tari_utilities::convert::try_convert_all, transactions::aggregated_body::AggregateBody}; use crate::tari_rpc as grpc; diff --git a/base_layer/core/src/proto/mod.rs b/base_layer/core/src/proto/mod.rs index e555a36de7..f097724dae 100644 --- a/base_layer/core/src/proto/mod.rs +++ b/base_layer/core/src/proto/mod.rs @@ -51,4 +51,4 @@ mod block; #[cfg(any(feature = "base_node", feature = "base_node_proto"))] mod block_header; #[cfg(any(feature = "base_node", feature = "base_node_proto"))] -pub mod utils; +mod utils; diff --git a/base_layer/core/src/proto/transaction.rs b/base_layer/core/src/proto/transaction.rs index 4ee0f6e7c1..fc96ee43ac 100644 --- a/base_layer/core/src/proto/transaction.rs +++ b/base_layer/core/src/proto/transaction.rs @@ -162,7 +162,7 @@ impl TryFrom for TransactionOutput { let sender_offset_public_key = PublicKey::from_bytes(output.sender_offset_public_key.as_bytes()).map_err(|err| format!("{:?}", err))?; - let script = TariScript::from_bytes(&output.script.to_vec()).map_err(|err| err.to_string())?; + let script = TariScript::from_bytes(&output.script).map_err(|err| err.to_string())?; let metadata_signature = output .metadata_signature diff --git a/base_layer/core/src/proto/utils.rs b/base_layer/core/src/proto/utils.rs index 0fb2635014..6e8738995a 100644 --- a/base_layer/core/src/proto/utils.rs +++ b/base_layer/core/src/proto/utils.rs @@ -21,23 +21,8 @@ // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use prost_types::Timestamp; -use std::convert::TryInto; use tari_crypto::tari_utilities::epoch_time::EpochTime; -/// Tries to convert a series of `T`s to `U`s, returning an error at the first failure -pub fn try_convert_all(into_iter: I) -> Result, T::Error> -where - I: IntoIterator, - T: TryInto, -{ - let iter = into_iter.into_iter(); - let mut result = Vec::with_capacity(iter.size_hint().0); - for item in iter { - result.push(item.try_into()?); - } - Ok(result) -} - /// Utility function that converts a `prost::Timestamp` to a `chrono::DateTime` pub(crate) fn timestamp_to_datetime(timestamp: Timestamp) -> EpochTime { (timestamp.seconds as u64).into()