diff --git a/firewood/src/stream.rs b/firewood/src/stream.rs index 40e27bd91..15038b2cd 100644 --- a/firewood/src/stream.rs +++ b/firewood/src/stream.rs @@ -375,6 +375,7 @@ enum PathIteratorState<'a> { } /// Iterates over all nodes on the path to a given key starting from the root. +/// /// All nodes are branch nodes except possibly the last, which may be a leaf. /// All returned nodes have keys which are a prefix of the given key. /// If the given key is in the trie, the last node is at that key. @@ -1262,9 +1263,8 @@ mod tests { let mut merkle = create_test_merkle(); let keys: Vec<_> = children - .map(|key| { - merkle.insert(&key, key.clone().into()).unwrap(); - key + .inspect(|key| { + merkle.insert(key, key.clone().into()).unwrap(); }) .collect(); diff --git a/firewood/src/v2/propose.rs b/firewood/src/v2/propose.rs index 4fa6ee490..a03ab5abc 100644 --- a/firewood/src/v2/propose.rs +++ b/firewood/src/v2/propose.rs @@ -68,7 +68,7 @@ impl Clone for ProposalBase { #[derive(Debug)] pub struct Proposal { pub(crate) base: ProposalBase, - pub(crate) delta: BTreeMap, KeyOp>>, + pub(crate) delta: BTreeMap, KeyOp>>, } // Implement Clone because T doesn't need to be Clone @@ -90,12 +90,15 @@ impl Proposal { let delta = batch .into_iter() .map(|op| match op { - api::BatchOp::Put { key, value } => { - (key.as_ref().to_vec(), KeyOp::Put(value.as_ref().to_vec())) + api::BatchOp::Put { key, value } => ( + key.as_ref().to_vec().into_boxed_slice(), + KeyOp::Put(value.as_ref().to_vec().into_boxed_slice()), + ), + api::BatchOp::Delete { key } => { + (key.as_ref().to_vec().into_boxed_slice(), KeyOp::Delete) } - api::BatchOp::Delete { key } => (key.as_ref().to_vec(), KeyOp::Delete), }) - .collect(); + .collect::>(); Arc::new(Self { base, delta }) } @@ -115,7 +118,7 @@ impl api::DbView for Proposal { match self.delta.get(key.as_ref()) { Some(change) => match change { // key in proposal, check for Put or Delete - KeyOp::Put(val) => Ok(Some(val.clone().into_boxed_slice())), + KeyOp::Put(val) => Ok(Some(val.clone())), KeyOp::Delete => Ok(None), // key was deleted in this proposal }, None => match &self.base { diff --git a/storage/src/nodestore.rs b/storage/src/nodestore.rs index 27413cde0..327a4f6c6 100644 --- a/storage/src/nodestore.rs +++ b/storage/src/nodestore.rs @@ -240,6 +240,7 @@ impl NodeStore { } /// Some nodestore kinds implement Parentable. +/// /// This means that the nodestore can have children. /// Only [ImmutableProposal] and [Committed] implement this trait. /// [MutableProposal] does not implement this trait because it is not a valid parent. @@ -709,6 +710,7 @@ where } /// Contains the state of a revision of a merkle trie. +/// /// The first generic parameter is the type of the revision, which supports reading nodes from parent proposals. /// The second generic parameter is the type of the storage used, either /// in-memory or on-disk.