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
[Wallet] slighly refactor GetOldestKeyPoolTime() #7816
[Wallet] slighly refactor GetOldestKeyPoolTime() #7816
Conversation
This is meant to fix #7794 |
if (nIndex == -1) | ||
LOCK(cs_wallet); | ||
|
||
// is the keypool is empty, return <NOW> |
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.
Typo: if
tests fail with:
|
int64_t nIndex = *(setKeyPool.begin()); | ||
setKeyPool.erase(setKeyPool.begin()); | ||
if (!walletdb.ReadPool(nIndex, keypool)) | ||
throw runtime_error("GetOldestKeyPoolTime(): read oldest key in keypool failed"); |
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.
How do you know it is GetOldestKeyPoolTime
who failed?
Edit: Ah, please use __func__
;-))
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.
Thanks. But lets keep GetOldestKeyPoolTime():
for now and let it open if someone wants to change the whole wallet sources to make use of __func__
. Mixing would be worse IMO.
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.
Sorry, this is like using TABs to indent and say that it is OK to use TABs, and later someone could reformat it completely with clang-format
. I thought we already agreed that in new code, we should follow our best practice (and as you see on my example above, it can even fool people). And it is shorter ;-)
a77bb10
to
8baf363
Compare
Fixed the bug (accidentally erase keypool key) that caused the test to fail. |
So if the keypool is empty, you are returning NOW. RPC
This is a slight change in the semantic, but I think it is OK. |
minor nit: commit message typo slighly-> slightly (sorry for noticing all these unimportant things, please bear with me...). |
8baf363
to
9f7336b
Compare
I think this was already the case before. Thanks. Fixed the commit typo. I'm happy if you point to nits/typos. |
Yes, the |
9f7336b [Wallet] slightly refactor GetOldestKeyPoolTime() (Jonas Schnelli)
Not sure if this solution is much better.
We don't keep keypool keys in memory (only a 64bit identifier), therefore a DB operation is required.
Another solution would be to do a in-mem cache of the oldest key.
This solution, at least, does not retain and release the key.