Skip to content

Commit

Permalink
improvement: implement State for Arc<StateRef>
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann committed Feb 8, 2023
1 parent 8c22748 commit 97ab72f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions crates/primitives/src/db/components/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,26 @@ where
StateRef::storage(*self, address, index)
}
}

#[cfg(feature = "std")]
impl<T> State for std::sync::Arc<T>
where
T: StateRef,
{
type Error = <T as StateRef>::Error;

fn basic(&mut self, address: B160) -> Result<Option<AccountInfo>, Self::Error> {
use std::ops::Deref;
self.deref().basic(address)
}

fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error> {
use std::ops::Deref;
self.deref().code_by_hash(code_hash)
}

fn storage(&mut self, address: B160, index: U256) -> Result<U256, Self::Error> {
use std::ops::Deref;
self.deref().storage(address, index)
}
}

0 comments on commit 97ab72f

Please sign in to comment.