diff --git a/firewood/examples/rev.rs b/firewood/examples/rev.rs index c5fc7cfa9..0faac609b 100644 --- a/firewood/examples/rev.rs +++ b/firewood/examples/rev.rs @@ -162,7 +162,7 @@ impl RevisionTracker { fn get_revision(&self, index: usize) -> Revision { self.db - .get_revision(&self.hashes[index], None) + .get_revision(&self.hashes[index]) .unwrap_or_else(|| panic!("revision-{index} should exist")) } } diff --git a/firewood/src/api.rs b/firewood/src/api.rs index 80eed118e..353a65952 100644 --- a/firewood/src/api.rs +++ b/firewood/src/api.rs @@ -3,7 +3,7 @@ use std::io::Write; -use crate::db::{DbError, DbRevConfig}; +use crate::db::DbError; use crate::merkle::TrieHash; #[cfg(feature = "proof")] use crate::{merkle::MerkleError, proof::Proof}; @@ -14,7 +14,7 @@ pub type Nonce = u64; #[async_trait] pub trait Db { - async fn get_revision(&self, root_hash: TrieHash, cfg: Option) -> Option; + async fn get_revision(&self, root_hash: TrieHash) -> Option; } #[async_trait] diff --git a/firewood/src/db.rs b/firewood/src/db.rs index c1a9d1cb8..f587f3632 100644 --- a/firewood/src/db.rs +++ b/firewood/src/db.rs @@ -806,11 +806,7 @@ impl Db { /// /// If no revision with matching root hash found, returns None. // #[measure([HitCount])] - pub fn get_revision( - &self, - root_hash: &TrieHash, - cfg: Option, - ) -> Option> { + pub fn get_revision(&self, root_hash: &TrieHash) -> Option> { let mut revisions = self.revisions.lock(); let inner_lock = self.inner.read(); @@ -883,8 +879,6 @@ impl Db { // Release the lock after we find the revision drop(inner_lock); - let cfg = cfg.as_ref().unwrap_or(&self.cfg.rev); - let db_header_ref = Db::get_db_header_ref(&space.merkle.meta).unwrap(); let merkle_payload_header_ref = @@ -906,7 +900,7 @@ impl Db { (space.blob.meta.clone(), space.blob.payload.clone()), self.payload_regn_nbit, 0, - cfg, + &self.cfg.rev, ) .unwrap(), } diff --git a/firewood/src/service/client.rs b/firewood/src/service/client.rs index fcddca26e..c3f44dd9c 100644 --- a/firewood/src/service/client.rs +++ b/firewood/src/service/client.rs @@ -12,7 +12,7 @@ use std::{path::Path, thread}; use tokio::sync::{mpsc, oneshot}; use crate::api::Revision; -use crate::db::DbRevConfig; + use crate::{ db::{DbConfig, DbError}, merkle::TrieHash, @@ -181,15 +181,10 @@ impl crate::api::Db for Connection where tokio::sync::mpsc::Sender: From>, { - async fn get_revision( - &self, - root_hash: TrieHash, - cfg: Option, - ) -> Option { + async fn get_revision(&self, root_hash: TrieHash) -> Option { let (send, recv) = oneshot::channel(); let msg = Request::NewRevision { root_hash, - cfg, respond_to: send, }; self.sender diff --git a/firewood/src/service/mod.rs b/firewood/src/service/mod.rs index 0db87a86a..47ac8ff34 100644 --- a/firewood/src/service/mod.rs +++ b/firewood/src/service/mod.rs @@ -3,10 +3,7 @@ use tokio::sync::{mpsc, oneshot}; -use crate::{ - db::{DbError, DbRevConfig}, - merkle::TrieHash, -}; +use crate::{db::DbError, merkle::TrieHash}; mod client; mod server; @@ -25,7 +22,6 @@ pub struct RevisionHandle { pub enum Request { NewRevision { root_hash: TrieHash, - cfg: Option, respond_to: oneshot::Sender>, }, diff --git a/firewood/src/service/server.rs b/firewood/src/service/server.rs index 278cc7530..779efce3e 100644 --- a/firewood/src/service/server.rs +++ b/firewood/src/service/server.rs @@ -39,11 +39,10 @@ impl FirewoodService { match msg { Request::NewRevision { root_hash, - cfg, respond_to, } => { let id: RevId = lastid.fetch_add(1, Ordering::Relaxed); - let msg = match db.get_revision(&root_hash, cfg) { + let msg = match db.get_revision(&root_hash) { Some(rev) => { revs.insert(id, rev); Some(id) diff --git a/firewood/tests/db.rs b/firewood/tests/db.rs index d7399b276..dd512128d 100644 --- a/firewood/tests/db.rs +++ b/firewood/tests/db.rs @@ -130,7 +130,7 @@ fn test_revisions() { dumped .iter() .zip(hashes.iter().cloned()) - .map(|(data, hash)| (data, db.get_revision(&hash, None).unwrap())) + .map(|(data, hash)| (data, db.get_revision(&hash).unwrap())) .map(|(data, rev)| (data, kv_dump!(rev))) .for_each(|(b, a)| { if &a != b { @@ -144,7 +144,7 @@ fn test_revisions() { dumped .iter() .zip(hashes.iter().cloned()) - .map(|(data, hash)| (data, db.get_revision(&hash, None).unwrap())) + .map(|(data, hash)| (data, db.get_revision(&hash).unwrap())) .map(|(data, rev)| (data, kv_dump!(rev))) .for_each(|(previous_dump, after_reopen_dump)| { if &after_reopen_dump != previous_dump { @@ -208,7 +208,7 @@ fn create_db_issue_proof() { let proposal = db.new_proposal(batch).unwrap(); proposal.commit().unwrap(); - let rev = db.get_revision(&root_hash, None).unwrap(); + let rev = db.get_revision(&root_hash).unwrap(); let key = "doe".as_bytes(); let root_hash = rev.kv_root_hash();