Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: minor clippy fixes #3576

Merged
merged 3 commits into from
Nov 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion base_layer/core/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion base_layer/core/src/proto/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl TryFrom<proto::types::TransactionOutput> 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
Expand Down
15 changes: 0 additions & 15 deletions base_layer/core/src/proto/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, U, I>(into_iter: I) -> Result<Vec<U>, T::Error>
where
I: IntoIterator<Item = T>,
T: TryInto<U>,
{
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()
Expand Down