From 97ab72f16abb4666b8bca75ff82acfe2577d66c6 Mon Sep 17 00:00:00 2001 From: Wodann Date: Sat, 28 Jan 2023 12:27:49 -0300 Subject: [PATCH] improvement: implement State for Arc --- crates/primitives/src/db/components/state.rs | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crates/primitives/src/db/components/state.rs b/crates/primitives/src/db/components/state.rs index 3f9d3e5f6c..5c86bf44cd 100644 --- a/crates/primitives/src/db/components/state.rs +++ b/crates/primitives/src/db/components/state.rs @@ -48,3 +48,26 @@ where StateRef::storage(*self, address, index) } } + +#[cfg(feature = "std")] +impl State for std::sync::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) + } +}