@@ -3081,11 +3081,15 @@ bool CWallet::NewKeyPool()
3081
3081
{
3082
3082
LOCK (cs_wallet);
3083
3083
CWalletDB walletdb (*dbw);
3084
- for (int64_t nIndex : setInternalKeyPool)
3084
+
3085
+ for (int64_t nIndex : setInternalKeyPool) {
3085
3086
walletdb.ErasePool (nIndex);
3087
+ }
3086
3088
setInternalKeyPool.clear ();
3087
- BOOST_FOREACH (int64_t nIndex, setExternalKeyPool)
3089
+
3090
+ for (int64_t nIndex : setExternalKeyPool) {
3088
3091
walletdb.ErasePool (nIndex);
3092
+ }
3089
3093
setExternalKeyPool.clear ();
3090
3094
3091
3095
if (!TopUpKeyPool ()) {
@@ -3132,12 +3136,16 @@ bool CWallet::TopUpKeyPool(unsigned int kpSize)
3132
3136
for (int64_t i = missingInternal + missingExternal; i--;)
3133
3137
{
3134
3138
int64_t nEnd = 1 ;
3135
- if (i < missingInternal)
3139
+ if (i < missingInternal) {
3136
3140
internal = true ;
3137
- if (!setInternalKeyPool.empty ())
3141
+ }
3142
+
3143
+ if (!setInternalKeyPool.empty ()) {
3138
3144
nEnd = *(--setInternalKeyPool.end ()) + 1 ;
3139
- if (!setExternalKeyPool.empty ())
3145
+ }
3146
+ if (!setExternalKeyPool.empty ()) {
3140
3147
nEnd = std::max (nEnd, *(--setExternalKeyPool.end ()) + 1 );
3148
+ }
3141
3149
3142
3150
if (!walletdb.WritePool (nEnd, CKeyPool (GenerateNewKey (internal), internal)))
3143
3151
throw std::runtime_error (std::string (__func__) + " : writing generated key failed" );
@@ -3238,8 +3246,9 @@ static int64_t GetOldestKeyTimeInPool(const std::set<int64_t>& setKeyPool, CWall
3238
3246
3239
3247
CKeyPool keypool;
3240
3248
int64_t nIndex = *(setKeyPool.begin ());
3241
- if (!walletdb.ReadPool (nIndex, keypool))
3249
+ if (!walletdb.ReadPool (nIndex, keypool)) {
3242
3250
throw std::runtime_error (std::string (__func__) + " : read oldest key in keypool failed" );
3251
+ }
3243
3252
assert (keypool.vchPubKey .IsValid ());
3244
3253
return keypool.nTime ;
3245
3254
}
@@ -3434,8 +3443,9 @@ void CReserveKey::KeepKey()
3434
3443
3435
3444
void CReserveKey::ReturnKey ()
3436
3445
{
3437
- if (nIndex != -1 )
3446
+ if (nIndex != -1 ) {
3438
3447
pwallet->ReturnKey (nIndex, fInternal );
3448
+ }
3439
3449
nIndex = -1 ;
3440
3450
vchPubKey = CPubKey ();
3441
3451
}
0 commit comments