-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address Discovery (Sequential) #51
Address Discovery (Sequential) #51
Conversation
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!
AddressPoolGap (toEnum g) | ||
|
||
-- | Smart constructor for 'AddressPoolGap' | ||
mkAddressPoolGap :: Word8 -> Either MkAddressPoolGapError AddressPoolGap |
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.
don't we want :
mkAddressPoolGap
:: Word8
-> Either MkAddressPoolGapError AddressPoolGap
?
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.
Not necessarily. The line is still within 80 chars, so we don't necessarily have to wrap it.
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.
👍
-- In practice, we always have: | ||
-- | ||
-- > mkAddressPool key g cc (addresses pool) == pool | ||
addresses :: AddressPool -> [Address] |
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.
the same comment as above
| otherwise = pool | ||
where | ||
edge = Map.size (indexedAddresses pool) | ||
isOnEdge = edge - fromEnum ix <= fromEnum (gap pool) |
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.
the definition of isOnEdge
follows from the standard?
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.
Well, the specification is rather evasive about how this should be handled.
- scan addresses of the external chain; respect the gap limit described below
- if no transactions are found on the external chain, stop discovery
The approach above is how we've translated this, and works fairly well (cf property tests)
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.
👍
newAddress = keyToAddress . deriveAddressPublicKey key cc | ||
|
||
-- | Fails hard if an invariant does not hold, or proceed. | ||
invariant |
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 it is good idea to extract invariant
function in helper file or use the one already defined in src/Cardano/Wallet.hs
:
173:invariant
174- :: String -- ^ A title / message to throw in case of violation
175- -> a
176- -> (a -> Bool)
177- -> a
178:invariant msg a predicate
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.
Whoops. My bad. I intended to use the one from src/Cardano/Wallet.hs
indeed, though I hadn't rebase yet at this moment and just copy/pasted it quickly. Will remove 👍
35cb00e
to
63e9070
Compare
e89cd11
to
1a5805c
Compare
1a5805c
to
d0b1c37
Compare
Issue Number
#22
Overview
cardano-wallet-legacy
AddressPool
module according to the findings in the prototype, also making it a plain data-structure rather than accepting a function in its internal representationComments