diff --git a/src/database/abstraction.rs b/src/database/abstraction.rs index fdf93089..d620fa76 100644 --- a/src/database/abstraction.rs +++ b/src/database/abstraction.rs @@ -39,20 +39,35 @@ pub(crate) trait KvTree: Send + Sync { } fn insert(&self, key: &[u8], value: &[u8]) -> Result<()>; - fn insert_batch(&self, iter: &mut dyn Iterator, Vec)>) -> Result<()>; + fn insert_batch(&self, iter: &mut dyn Iterator, Vec)>) -> Result<()> { + for (key, value) in iter { + self.insert(&key, &value)?; + } + + Ok(()) + } fn remove(&self, key: &[u8]) -> Result<()>; + fn remove_batch(&self, iter: &mut dyn Iterator>) -> Result<()> { + for key in iter { + self.remove(&key)?; + } - #[allow(dead_code)] - #[cfg(feature = "rocksdb")] - fn remove_batch(&self, _iter: &mut dyn Iterator>) -> Result<()> { unimplemented!() } + Ok(()) + } fn iter<'a>(&'a self) -> Box, Vec)> + 'a>; fn iter_from<'a>(&'a self, from: &[u8], backwards: bool) -> Box, Vec)> + 'a>; fn increment(&self, key: &[u8]) -> Result>; - fn increment_batch(&self, iter: &mut dyn Iterator>) -> Result<()>; + fn increment_batch(&self, iter: &mut dyn Iterator>) -> Result<()> { + for key in iter { + self.increment(&key)?; + } + + Ok(()) + } fn scan_prefix<'a>(&'a self, prefix: Vec) -> Box, Vec)> + 'a>;