Merge pull request #85 from zcash/caching

Add `CachingShardStore` for batching writes to a backend `ShardStore`
This commit is contained in:
str4d 2023-07-17 22:00:43 +01:00 committed by GitHub
commit 099abbfc40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1263 additions and 1 deletions

View File

@ -36,4 +36,5 @@ test-dependencies = ["proptest", "assert_matches"]
[target.'cfg(unix)'.dev-dependencies]
pprof = { version = "0.9", features = ["criterion", "flamegraph"] } # MSRV 1.56
dashmap = ">=5, <5.5.0"
inferno = ">=0.11, <0.11.5" # MSRV 1.59

1253
shardtree/src/caching.rs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,7 @@ pub use self::prunable::{
IncompleteAt, InsertionError, LocatedPrunableTree, PrunableTree, QueryError, RetentionFlags,
};
pub mod caching;
pub mod memory;
#[cfg(any(bench, test, feature = "test-dependencies"))]
@ -178,9 +179,11 @@ pub trait ShardStore {
F: Fn(&mut Checkpoint) -> Result<(), Self::Error>;
/// Removes a checkpoint from the data store.
///
/// If no checkpoint exists with the given ID, this does nothing.
fn remove_checkpoint(&mut self, checkpoint_id: &Self::CheckpointId) -> Result<(), Self::Error>;
/// Removes checkpoints with identifiers greater than or equal to the given identifier
/// Removes checkpoints with identifiers greater than or equal to the given identifier.
fn truncate_checkpoints(
&mut self,
checkpoint_id: &Self::CheckpointId,
@ -364,6 +367,11 @@ impl<
}
}
/// Consumes this tree and returns its underlying `ShardStore`.
pub fn into_store(self) -> S {
self.store
}
/// Returns the root address of the tree.
pub fn root_addr() -> Address {
Address::from_parts(Level::from(DEPTH), 0)