Add counter-resets to reset_modifications

This commit is contained in:
Paul Hauner 2019-04-29 10:57:19 +10:00
parent 0599d3f1f8
commit fbf8fad4f1
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6

View File

@ -45,11 +45,6 @@ impl TreeHashCache {
if self.is_empty() { if self.is_empty() {
Err(Error::CacheNotInitialized) Err(Error::CacheNotInitialized)
} else { } else {
// Reset the per-hash counters.
self.chunk_index = 0;
self.schema_index = 0;
// Reset the "modified" flags for the cache.
self.reset_modifications(); self.reset_modifications();
item.update_tree_hash_cache(self) item.update_tree_hash_cache(self)
@ -156,6 +151,10 @@ impl TreeHashCache {
} }
pub fn reset_modifications(&mut self) { pub fn reset_modifications(&mut self) {
// Reset the per-hash counters.
self.chunk_index = 0;
self.schema_index = 0;
for chunk_modified in &mut self.chunk_modified { for chunk_modified in &mut self.chunk_modified {
*chunk_modified = false; *chunk_modified = false;
} }
@ -243,6 +242,10 @@ impl TreeHashCache {
self.cache.len() self.cache.len()
} }
pub fn tree_hash_root(&self) -> Result<&[u8], Error> {
self.root()
}
pub fn root(&self) -> Result<&[u8], Error> { pub fn root(&self) -> Result<&[u8], Error> {
if self.is_empty() { if self.is_empty() {
Err(Error::CacheNotInitialized) Err(Error::CacheNotInitialized)