Skip to content
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

Merged
merged 1 commit into from Apr 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/wallet/wallet.cpp
Expand Up @@ -2611,12 +2611,19 @@ bool CWallet::GetKeyFromPool(CPubKey& result)

int64_t CWallet::GetOldestKeyPoolTime()
{
int64_t nIndex = 0;
CKeyPool keypool;
ReserveKeyFromKeyPool(nIndex, keypool);
if (nIndex == -1)
LOCK(cs_wallet);

// if the keypool is empty, return <NOW>
if (setKeyPool.empty())
return GetTime();
ReturnKey(nIndex);

// load oldest key from keypool, get time and return
CKeyPool keypool;
CWalletDB walletdb(strWalletFile);
int64_t nIndex = *(setKeyPool.begin());
if (!walletdb.ReadPool(nIndex, keypool))
throw runtime_error("GetOldestKeyPoolTime(): read oldest key in keypool failed");
assert(keypool.vchPubKey.IsValid());
return keypool.nTime;
}

Expand Down