-
Notifications
You must be signed in to change notification settings - Fork 12
clean-up access to encrypted secret keys and address pools construction #360
base: develop
Are you sure you want to change the base?
Conversation
This is in preparation of some upcoming restructuring where we get rid of the HdAccountBase and replace it with an HdRootBase. This will ultimately remove a lot of errors linked to the possible inconsistency we could get across all accounts of a root. This particular restructuring move some responsibility to the callers of getESK and getPools and purify a bit those primitives functions. This way, we leave to the caller to decide what to do when something goes wrong. In this particular case, we fail hard with an invariant violation
:: DB | ||
-> HdAccountId | ||
-> [(Address, Word32)] | ||
addressesByAccountId' _db accId = addressesByAccountId db accId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the first argument is not used - why do we need it? Maybe just remove _db
?
-- NOTE: | ||
-- We arbitrarily take the maximum AddressPoolGap here. This is rather | ||
-- incorrect but will go away with the next PR as part of #357! | ||
externallyOwnedRoots |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we have to unify our naming? I mean that in some places we use a full form externallyOwned
, but in other places we use a short one, EO
...
invariantFO :: HdRootId -> Maybe a -> IO a | ||
invariantFO rootId = flip maybe return $ fail $ toString $ | ||
"Cardano.Wallet.Kernel.BListener: invariant violation: encrypted secret key \ | ||
\hasn't been found for the given root id: " <> sformat build rootId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just match explicitly?
invariantFO :: HdRootId -> Maybe a -> IO a
invariantFO rootId (Just k) = return k
invariantFO rootId Nothing = fail $ toString $
"Cardano.Wallet.Kernel.BListener: invariant violation: encrypted secret key \
\hasn't been found for the given root id: " <> sformat build rootId
And the same for invariantEO
..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I've asked some little questions though..
#357
Overview
This is in preparation of some upcoming restructuring where we get rid of the HdAccountBase and replace it with an HdRootBase. This will ultimately remove a lot of errors linked to the possible
inconsistency we could get across all accounts of a root.
This particular restructuring move some responsibility to the callers of getESK and getPools and
purify a bit those primitives functions. This way, we leave to the caller to decide what to do
when something goes wrong. In this particular case, we fail hard with an invariant violation
Comments