aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2017-03-24 10:54:48 +0100
committerJonas Schnelli <dev@jonasschnelli.ch>2017-03-24 10:54:48 +0100
commited79e4f497a9a7747b006a5cb04d4173a6bbc1c5 (patch)
tree179b5e801c450299e6c71dfed01f80973da74c99 /src/wallet
parent771a304ffe3c074a8ca1cdfb83d08379a5516e88 (diff)
Optimize GetOldestKeyPoolTime(), return as soon as we have both oldest keys
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 0a06879754..d7d2927ba2 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3069,12 +3069,18 @@ int64_t CWallet::GetOldestKeyPoolTime()
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");
- if (keypool.fInternal && keypool.nTime < oldest_internal)
+ }
+ if (keypool.fInternal && keypool.nTime < oldest_internal) {
oldest_internal = keypool.nTime;
- else if (!keypool.fInternal && keypool.nTime < oldest_external)
+ }
+ else if (!keypool.fInternal && keypool.nTime < oldest_external) {
oldest_external = keypool.nTime;
+ }
+ if (oldest_internal != now && oldest_external != now) {
+ break;
+ }
}
return std::max(oldest_internal, oldest_external);
}