//! `Database` implementation that flushes changes at the specified batches.
use std::any::Any;
use zksync_merkle_tree::{
unstable::{DeserializeError, Manifest, Node, NodeKey, ProfiledTreeOperation, Root},
Database, PatchSet, Patched,
};
pub struct WithBatching<'a> {
inner: Patched<&'a mut dyn Database>,
batch_size: usize,
in_memory_batch_size: usize,
}
impl<'a> WithBatching<'a> {
pub fn new(db: &'a mut dyn Database, batch_size: usize) -> Self {
assert!(batch_size > 0, "Batch size must be positive");
Self {
inner: Patched::new(db),
batch_size,
in_memory_batch_size: 0,
}
}
}
impl Database for WithBatching<'_> {
fn try_manifest(&self) -> Result