kindelia / Kindelia

An efficient, secure cryptocomputer
https://kindelia.org/
603 stars 39 forks source link

refactor(core): avoid unwrap, expect, panic in persistence.rs #259

Closed dan-da closed 1 year ago

dan-da commented 1 year ago

Addresses #247. (more to come)

This PR focuses on persistence.rs. Modifications to other files are just to handle the persistence changes.

persistence.rs:

node.rs:

dan-da commented 1 year ago

@racs4 I added a kindelia_core::util::FileSystemError. The purpose is to wrap std::io::Error for any filesystem calls, so that path and optionally context can be reported to the user.

Otherwise the user gets "write failed os error(27)" type errors, without even knowing the file. This is a pain point in rust, and it seems like they might address it soon. see https://github.com/rust-lang/rfcs/issues/2885

The new error type enables SimpleFileStorage to return rich errors cleanly, as path info does not necessarily belong in BlockStorageError.

It should also be useful for other places that presently return IoResult, for example. Basically any code that interacts with filesystem.


Also, I notice that if a review has been requested and not yet performed and then another commit is pushed, CI does not run. And there is no way to request another review.

I found that a workaround is to convert the PR to a draft and then back to a regular PR, at which point checks run again.

racs4 commented 1 year ago

I notice that if a review has been requested and not yet performed and then another commit is pushed, CI does not run.

I will try to fix this.