rusk-wallet: Refactor Wallet struct to make impossible states impossible #2972
Labels
fix:vulnerability
Issues related to fix vulnerabilities of the architecture or software
module:rusk-wallet
Issues related to rusk wallet
type:enhancement
Issues concerning code or feature improvement (performance, refactoring, etc)
Currently, our
Wallet
struct allows for an inconsistent state:This structure allows for an inconsistent state where
file
could beNone
whilefile_version
isSome(_)
, or vice versa. This not only introduces potential errors but also complicates the code, requiring unnecessary unwrapping of bothfile
andfile_version
even when one has already been successfully unwrapped. Consequently, the code becomes more verbose and harder to understand and maintain.A potential solution is to combine both values into a single data structure:
or
Expected behaviour
The design of the
Wallet
struct should prevent impossible state.The text was updated successfully, but these errors were encountered: