-
Notifications
You must be signed in to change notification settings - Fork 602
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
waddrmgr: optimize using each style functions #216
Conversation
This looks like the discussed approach. However, unless we plan to add the ability to allow inactive accounts (which I don't really currently foresee), the name should probably be EDIT: Addresses, on the other hand, are definitely intended to be active/inactive, so naming that |
Cool, let me correct the func names. |
Looks good. I know there are more coming, so I won't merge it until everything is done. |
Thanks, will be working on the remaining funcs. |
40a3d6b
to
eed9785
Compare
Updated the remaining funcs. Working on optimizing storage for active/inactive addresses as discussed. |
be38bef
to
545d909
Compare
Refactored to store all active addresses in a bucket and use it as an index while iterating over active addresses. Added upgrade path for migrating from used bucket to active bucket. Running some checks, will be up for review in a bit. |
30a7ff1
to
02ba28c
Compare
To avoid confusion, we should stick to differentiating active/inactive addresses. I've replaced all references to |
d4b89c6
to
e938d98
Compare
OK, ready for review. @davecgh |
Also renamed a few methods for consistency e.g |
Depends on #238 in the way we will treat used addresses since this PR rewoks active/inactive (used) addrs in addition to each-style functions. |
As discussed on IRC, an address can expire after a duration and become inactive while still remaining unused. Therefore, instead of assuming that addr not present in active bucket is used, we should have an explicit db flag on address row using a flag field which determines whether the address is used or not. Similarly, the address should be marked expired after a certain configurable duration. |
4df6f33
to
8b1c588
Compare
Limiting this PR to |
5915f39
to
0d7d4ce
Compare
_ = w.Manager.ForEachAccountAddress(account, | ||
func(maddr waddrmgr.ManagedAddress) error { | ||
used, err = maddr.Used() | ||
return nil |
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.
This throws away the error and re-assigns the possibly true used value instead of breaking out of the loop and returning true to the caller.
ActiveAccountAddresses wasn't switched over to the new style and I'd like to see some more details in each function comments about how it executes the passed function on each item, breaking early is an error is returned. Just saying "it iterates over X" isn't descriptive enough. |
0d7d4ce
to
8c56747
Compare
Moved |
All of the calls to maybeConvertDbError will mangle the break error. I think that errors from this package should be converted, but errors from a caller's callback should not be. |
5e9875d
to
54c5b8a
Compare
54c5b8a
to
fbf744b
Compare
Thanks, as discussed, I've added a global err |
ok |
Thanks |
refs #215
WIP: Trying out the approach by replacing
AllAccounts
with aeach
style func first.