diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-22 08:36:22 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-22 08:36:56 +0200 |
commit | 0c95ebce7e67f86f62c099974dde68c8d808240b (patch) | |
tree | a0192fc42efc43ead0625ede452aa5064dde341b /src/wallet | |
parent | 59ad56851a342d2c62f6b38bf15002b23ab439e1 (diff) | |
parent | 9f7336b4575b15193151dbf08b09562529a24363 (diff) |
Merge #7816: [Wallet] slighly refactor GetOldestKeyPoolTime()
9f7336b [Wallet] slightly refactor GetOldestKeyPoolTime() (Jonas Schnelli)
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 955a0a3d60..8f2425fb6b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2616,12 +2616,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; } |