Browse Source

[Wallet] slightly refactor GetOldestKeyPoolTime()

0.13
Jonas Schnelli 9 years ago
parent
commit
9f7336b457
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
  1. 17
      src/wallet/wallet.cpp

17
src/wallet/wallet.cpp

@ -2611,12 +2611,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;
} }

Loading…
Cancel
Save