linera-protocol
linera-protocol copied to clipboard
[nits] Introduce `into_saved(self)` for `RootView`.
So, now we have the pattern in fn save.
let mut batch = Batch::new();
view.pre_save(&mut batch)?;
store.write_batch(batch).await?;
view.post_save();
In the functions fn finalize of the smart contracts we often have the pattern
async fn store(mut self) {
self.state.save().await.expect("Failed to save state");
}
This means that the post_save is done for no reason (but maybe elided away by the compiler). It would make sense to have into_saved that does the pre_save, write_batch, but not the post_save.
(Or fn save_and_drop(self)?) Because it wouldn't return a Self anymore, would it? It would just consume it?
Yes, it would consume it. So yes save_and_drop makes sense.