mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-03 15:02:30 +02:00
Merge #7816: [Wallet] slighly refactor GetOldestKeyPoolTime()
9f7336b
[Wallet] slightly refactor GetOldestKeyPoolTime() (Jonas Schnelli)
This commit is contained in:
@@ -2616,12 +2616,19 @@ bool CWallet::GetKeyFromPool(CPubKey& result)
|
|||||||
|
|
||||||
int64_t CWallet::GetOldestKeyPoolTime()
|
int64_t CWallet::GetOldestKeyPoolTime()
|
||||||
{
|
{
|
||||||
int64_t nIndex = 0;
|
LOCK(cs_wallet);
|
||||||
CKeyPool keypool;
|
|
||||||
ReserveKeyFromKeyPool(nIndex, keypool);
|
// if the keypool is empty, return <NOW>
|
||||||
if (nIndex == -1)
|
if (setKeyPool.empty())
|
||||||
return GetTime();
|
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;
|
return keypool.nTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user