Skip to content

Commit

Permalink
fix: BufferedBlockstore#flush should not reset the write buffer. (#1096)
Browse files Browse the repository at this point in the history
Resetting the buffer was never advertised as a behaviour of this method.

This makes it possible to call flush multiple times to selectively flush
roots during its lifetime. Selective flushes are used to flush the event
AMTs as they are being produced.
  • Loading branch information
raulk committed Nov 16, 2022
1 parent 490121c commit b869b57
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions fvm/src/blockstore/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ where
{
/// Flushes the buffered cache based on the root node.
/// This will recursively traverse the cache and write all data connected by links to this
/// root Cid.
/// root Cid. Calling flush will not reset the write buffer.
fn flush(&self, root: &Cid) -> Result<()> {
let mut buffer = Vec::new();
let mut s = self.write.borrow_mut();
let s = self.write.borrow();
copy_rec(&s, *root, &mut buffer)?;

self.base.put_many_keyed(buffer)?;
*s = Default::default();

Ok(())
}
Expand Down

0 comments on commit b869b57

Please sign in to comment.