diff --git a/firewood/examples/rev.rs b/firewood/examples/rev.rs index 19107d830..70ce7cdfb 100644 --- a/firewood/examples/rev.rs +++ b/firewood/examples/rev.rs @@ -7,11 +7,10 @@ use firewood::{ db::{BatchOp, Db, DbConfig, Proposal, Revision, WalConfig}, merkle::{Node, TrieHash}, proof::Proof, - storage::{StoreRevMut, StoreRevShared}, + storage::StoreRevShared, }; use firewood_shale::compact::CompactSpace; -type Store = CompactSpace; type SharedStore = CompactSpace; /// cargo run --example rev @@ -142,7 +141,7 @@ impl RevisionTracker { self.hashes.push_front(hash); } - fn commit_proposal(&mut self, proposal: Proposal) { + fn commit_proposal(&mut self, proposal: Proposal) { proposal.commit().unwrap(); let hash = self.db.kv_root_hash().expect("root-hash should exist"); self.hashes.push_front(hash); diff --git a/firewood/src/db.rs b/firewood/src/db.rs index 619da819c..0cf1e70af 100644 --- a/firewood/src/db.rs +++ b/firewood/src/db.rs @@ -750,10 +750,7 @@ impl Db { } /// Create a proposal. - pub fn new_proposal>( - &self, - data: Batch, - ) -> Result, DbError> { + pub fn new_proposal>(&self, data: Batch) -> Result { let mut inner = self.inner.write(); let reset_store_headers = inner.reset_store_headers; let (store, mut rev) = Db::new_store( @@ -963,32 +960,29 @@ pub type Batch = Vec>; /// latest committed revision at the same time. [Proposal] is immutable meaning /// the internal batch cannot be altered after creation. Committing a proposal /// invalidates all other proposals that are not children of the committed one. -pub struct Proposal { +pub struct Proposal { // State of the Db m: Arc>, - r: Arc>>, + r: Arc>>, cfg: DbConfig, // State of the proposal - rev: DbRev, + rev: DbRev, store: Universe>, committed: Arc>, - parent: ProposalBase, + parent: ProposalBase, } -pub enum ProposalBase { - Proposal(Arc>), - View(Arc>), +pub enum ProposalBase { + Proposal(Arc), + View(Arc>), } -impl Proposal { +impl Proposal { // Propose a new proposal from this proposal. The new proposal will be // the child of it. - pub fn propose>( - self: Arc, - data: Batch, - ) -> Result, DbError> { + pub fn propose>(self: Arc, data: Batch) -> Result { let store = self.store.new_from_other(); let m = Arc::clone(&self.m); @@ -1236,13 +1230,13 @@ impl Proposal { } } -impl + Send + Sync, T: ShaleStore + Send + Sync> Proposal { - pub fn get_revision(&self) -> &DbRev { +impl Proposal { + pub fn get_revision(&self) -> &DbRev { &self.rev } } -impl Drop for Proposal { +impl Drop for Proposal { fn drop(&mut self) { if !*self.committed.lock() { // drop the staging changes