From f92375f6a61d72fa802e4a75ca7cba3f8d968363 Mon Sep 17 00:00:00 2001 From: Boog900 <54e72d8a-345f-4599-bd90-c6b9bc7d0ec5@aleeas.com> Date: Sat, 7 Sep 2024 02:07:23 +0100 Subject: [PATCH] clippy + fmt --- storage/blockchain/src/service/read.rs | 4 ++-- storage/blockchain/src/types.rs | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/storage/blockchain/src/service/read.rs b/storage/blockchain/src/service/read.rs index 416e613..835f2d6 100644 --- a/storage/blockchain/src/service/read.rs +++ b/storage/blockchain/src/service/read.rs @@ -14,13 +14,14 @@ use rayon::{ use thread_local::ThreadLocal; use cuprate_database::{ConcreteEnv, DatabaseRo, Env, EnvInner, RuntimeError}; -use cuprate_database_service::{DatabaseReadService, init_thread_pool, ReaderThreads}; +use cuprate_database_service::{init_thread_pool, DatabaseReadService, ReaderThreads}; use cuprate_helper::map::combine_low_high_bits_to_u128; use cuprate_types::{ blockchain::{BlockchainReadRequest, BlockchainResponse}, Chain, ChainId, ExtendedBlockHeader, OutputOnChain, }; +use crate::ops::alt_block::get_alt_block; use crate::{ ops::{ alt_block::{ @@ -43,7 +44,6 @@ use crate::{ AltBlockHeight, Amount, AmountIndex, BlockHash, BlockHeight, KeyImage, PreRctOutputId, }, }; -use crate::ops::alt_block::get_alt_block; //---------------------------------------------------------------------------------------------------- init_read_service /// Initialize the [`BlockchainReadHandle`] thread-pool backed by [`rayon`]. diff --git a/storage/blockchain/src/types.rs b/storage/blockchain/src/types.rs index 1491724..13c4499 100644 --- a/storage/blockchain/src/types.rs +++ b/storage/blockchain/src/types.rs @@ -44,12 +44,12 @@ use std::num::NonZero; use bytemuck::{Pod, Zeroable}; - #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use cuprate_database::{Key, StorableVec}; use cuprate_types::{Chain, ChainId}; + //---------------------------------------------------------------------------------------------------- Aliases // These type aliases exist as many Monero-related types are the exact same. // For clarity, they're given type aliases as to not confuse them. @@ -334,17 +334,15 @@ pub struct RawChain(u64); impl From for RawChain { fn from(value: Chain) -> Self { match value { - Chain::Main => RawChain(0), - Chain::Alt(chain_id) => RawChain(chain_id.0.get()), + Chain::Main => Self(0), + Chain::Alt(chain_id) => Self(chain_id.0.get()), } } } impl From for Chain { fn from(value: RawChain) -> Self { - NonZero::new(value.0) - .map(|id| Chain::Alt(ChainId(id))) - .unwrap_or(Chain::Main) + NonZero::new(value.0).map_or(Self::Main, |id| Self::Alt(ChainId(id))) } } @@ -352,7 +350,7 @@ impl From for RawChain { fn from(value: RawChainId) -> Self { assert_ne!(value.0, 0); - RawChain(value.0) + Self(value.0) } } @@ -363,13 +361,13 @@ pub struct RawChainId(u64); impl From for RawChainId { fn from(value: ChainId) -> Self { - RawChainId(value.0.get()) + Self(value.0.get()) } } impl From for ChainId { fn from(value: RawChainId) -> Self { - ChainId(NonZero::new(value.0).expect("RawChainId mut not have a value of `0`")) + Self(NonZero::new(value.0).expect("RawChainId mut not have a value of `0`")) } }