Skip to content

Commit

Permalink
Remove unnecessary wrapper around Revision (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuris authored Jan 4, 2024
1 parent 0e8ab96 commit 6e8c00d
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions firewood/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl api::Db for Db {
async fn revision(&self, root_hash: HashKey) -> Result<Arc<Self::Historical>, api::Error> {
let rev = self.get_revision(&TrieHash(root_hash));
if let Some(rev) = rev {
Ok(Arc::new(rev.rev))
Ok(Arc::new(rev))
} else {
Err(api::Error::HashNotFound {
provided: root_hash,
Expand Down Expand Up @@ -851,7 +851,7 @@ impl Db {
///
/// If no revision with matching root hash found, returns None.
// #[measure([HitCount])]
pub fn get_revision(&self, root_hash: &TrieHash) -> Option<Revision<SharedStore>> {
pub fn get_revision(&self, root_hash: &TrieHash) -> Option<DbRev<SharedStore>> {
let mut revisions = self.revisions.lock();
let inner_lock = self.inner.read();

Expand Down Expand Up @@ -938,16 +938,14 @@ impl Db {
let header_refs = (db_header_ref, merkle_payload_header_ref);

#[allow(clippy::unwrap_used)]
Revision {
rev: Db::new_revision(
header_refs,
(space.merkle.meta.clone(), space.merkle.payload.clone()),
self.payload_regn_nbit,
0,
&self.cfg.rev,
)
.unwrap(),
}
Db::new_revision(
header_refs,
(space.merkle.meta.clone(), space.merkle.payload.clone()),
self.payload_regn_nbit,
0,
&self.cfg.rev,
)
.unwrap()
.into()
}

Expand All @@ -964,15 +962,3 @@ impl Db {
self.metrics.clone()
}
}

/// Lock protected handle to a readable version of the DB.
pub struct Revision<S> {
rev: DbRev<S>,
}

impl<S> std::ops::Deref for Revision<S> {
type Target = DbRev<S>;
fn deref(&self) -> &DbRev<S> {
&self.rev
}
}

0 comments on commit 6e8c00d

Please sign in to comment.