Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.

clean-up access to encrypted secret keys and address pools construction #360

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

KtorZ
Copy link
Contributor

@KtorZ KtorZ commented Feb 22, 2019

#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

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
@KtorZ KtorZ self-assigned this Feb 22, 2019
:: DB
-> HdAccountId
-> [(Address, Word32)]
addressesByAccountId' _db accId = addressesByAccountId db accId
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

@denisshevchenko denisshevchenko Feb 25, 2019

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..

Copy link
Contributor

@denisshevchenko denisshevchenko left a 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..

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants