Make Write methods infallible
mappum opened this issue · comments
This is an experiment and could end up getting reverted, but now I realize that essentially all Store
writes can never error since they are just writing to in-memory data structures, and only ever get written to the actual on-disk database in one batch at the end of a block. If we change the Write
trait methods to not return Result
s, we can make types that write their value when dropped and probably do other convenient tricks.
Instead of using the Infallible
type, we can just change the Write
trait and add a TryWrite
for the lower-level database store interfaces (if necessary - they could also do the fallible writing in a flush method since they also just collect data in memory).
As I implement this I realize the higher-level state types will also need to encode values while writing - should encoding be infallible as well? 🤔
Deciding against this for now, in favor of allowing errors in drop()
via some sort of wrapper that collects errors to be consumed elsewhere.