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

improvement: implement BlockHash for Arc<BlockHashRef> #361

Merged
merged 1 commit into from
Feb 9, 2023
Merged
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
13 changes: 13 additions & 0 deletions crates/primitives/src/db/components/block_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,16 @@ where
BlockHashRef::block_hash(*self, number)
}
}

#[cfg(feature = "std")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is alloc::sync::Arc but to be honest I don't know if it would make a problem and if they can be interchangeably used

impl<T> BlockHash for std::sync::Arc<T>
where
T: BlockHashRef,
{
type Error = <T as BlockHashRef>::Error;

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