Browse Source

Optimize GetOldestKeyPoolTime(), return as soon as we have both oldest keys

0.15
Jonas Schnelli 8 years ago
parent
commit
ed79e4f497
No known key found for this signature in database
GPG Key ID: 1EB776BB03C7922D
  1. 12
      src/wallet/wallet.cpp

12
src/wallet/wallet.cpp

@ -3069,13 +3069,19 @@ int64_t CWallet::GetOldestKeyPoolTime()
for(const int64_t& id : setKeyPool) for(const int64_t& id : setKeyPool)
{ {
if (!walletdb.ReadPool(id, keypool)) if (!walletdb.ReadPool(id, keypool)) {
throw std::runtime_error(std::string(__func__) + ": read failed"); throw std::runtime_error(std::string(__func__) + ": read failed");
if (keypool.fInternal && keypool.nTime < oldest_internal) }
if (keypool.fInternal && keypool.nTime < oldest_internal) {
oldest_internal = keypool.nTime; oldest_internal = keypool.nTime;
else if (!keypool.fInternal && keypool.nTime < oldest_external) }
else if (!keypool.fInternal && keypool.nTime < oldest_external) {
oldest_external = keypool.nTime; oldest_external = keypool.nTime;
} }
if (oldest_internal != now && oldest_external != now) {
break;
}
}
return std::max(oldest_internal, oldest_external); return std::max(oldest_internal, oldest_external);
} }
// load oldest key from keypool, get time and return // load oldest key from keypool, get time and return

Loading…
Cancel
Save