From 711ef10d6bf1380989617bed1cf38f7969686848 Mon Sep 17 00:00:00 2001 From: Wodann Date: Thu, 9 Feb 2023 12:17:23 -0600 Subject: [PATCH] improvement: use alloc & core for Arc impl --- crates/primitives/src/db/components/block_hash.rs | 6 +++--- crates/primitives/src/db/components/state.rs | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/crates/primitives/src/db/components/block_hash.rs b/crates/primitives/src/db/components/block_hash.rs index 131c63e792..f5b6959003 100644 --- a/crates/primitives/src/db/components/block_hash.rs +++ b/crates/primitives/src/db/components/block_hash.rs @@ -2,7 +2,9 @@ //! it is used inside [crate::db::DatabaseComponents`] use crate::{B256, U256}; +use alloc::sync::Arc; use auto_impl::auto_impl; +use core::ops::Deref; #[auto_impl(& mut, Box)] pub trait BlockHash { @@ -31,15 +33,13 @@ where } } -#[cfg(feature = "std")] -impl BlockHash for std::sync::Arc +impl BlockHash for Arc where T: BlockHashRef, { type Error = ::Error; fn block_hash(&mut self, number: U256) -> Result { - use std::ops::Deref; self.deref().block_hash(number) } } diff --git a/crates/primitives/src/db/components/state.rs b/crates/primitives/src/db/components/state.rs index 5c86bf44cd..ce38ffb6c0 100644 --- a/crates/primitives/src/db/components/state.rs +++ b/crates/primitives/src/db/components/state.rs @@ -2,7 +2,9 @@ //! it is used inside [crate::db::DatabaseComponents`] use crate::{AccountInfo, Bytecode, B160, B256, U256}; +use alloc::sync::Arc; use auto_impl::auto_impl; +use core::ops::Deref; #[auto_impl(& mut, Box)] pub trait State { @@ -49,25 +51,21 @@ where } } -#[cfg(feature = "std")] -impl State for std::sync::Arc +impl State for Arc where T: StateRef, { type Error = ::Error; fn basic(&mut self, address: B160) -> Result, Self::Error> { - use std::ops::Deref; self.deref().basic(address) } fn code_by_hash(&mut self, code_hash: B256) -> Result { - use std::ops::Deref; self.deref().code_by_hash(code_hash) } fn storage(&mut self, address: B160, index: U256) -> Result { - use std::ops::Deref; self.deref().storage(address, index) } }