Skip to content

Commit e86eb71

Browse files
committed
Move CWallet::setKeyPool to private section of CWallet
1 parent ea26874 commit e86eb71

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

src/init.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,9 +1439,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
14391439
LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
14401440
LogPrintf("nBestHeight = %d\n", chainActive.Height());
14411441
#ifdef ENABLE_WALLET
1442-
LogPrintf("setKeyPool.size() = %u\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
1443-
LogPrintf("mapWallet.size() = %u\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
1444-
LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
1442+
if (pwalletMain) {
1443+
LOCK(pwalletMain->cs_wallet);
1444+
LogPrintf("setKeyPool.size() = %u\n", pwalletMain->GetKeyPoolSize());
1445+
LogPrintf("mapWallet.size() = %u\n", pwalletMain->mapWallet.size());
1446+
LogPrintf("mapAddressBook.size() = %u\n", pwalletMain->mapAddressBook.size());
1447+
}
14451448
#endif
14461449

14471450
if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION))

src/wallet/wallet.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
582582
CHDChain hdChain;
583583

584584
bool fFileBacked;
585+
586+
std::set<int64_t> setKeyPool;
585587
public:
586588
/*
587589
* Main wallet lock.
@@ -594,7 +596,18 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
594596

595597
std::string strWalletFile;
596598

597-
std::set<int64_t> setKeyPool;
599+
void LoadKeyPool(int nIndex, const CKeyPool &keypool)
600+
{
601+
setKeyPool.insert(nIndex);
602+
603+
// If no metadata exists yet, create a default with the pool key's
604+
// creation time. Note that this may be overwritten by actually
605+
// stored metadata for that key later, which is fine.
606+
CKeyID keyid = keypool.vchPubKey.GetID();
607+
if (mapKeyMetadata.count(keyid) == 0)
608+
mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime);
609+
}
610+
598611
std::map<CKeyID, CKeyMetadata> mapKeyMetadata;
599612

600613
typedef std::map<unsigned int, CMasterKey> MasterKeyMap;

src/wallet/walletdb.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
556556
ssKey >> nIndex;
557557
CKeyPool keypool;
558558
ssValue >> keypool;
559-
pwallet->setKeyPool.insert(nIndex);
560-
561-
// If no metadata exists yet, create a default with the pool key's
562-
// creation time. Note that this may be overwritten by actually
563-
// stored metadata for that key later, which is fine.
564-
CKeyID keyid = keypool.vchPubKey.GetID();
565-
if (pwallet->mapKeyMetadata.count(keyid) == 0)
566-
pwallet->mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime);
559+
560+
pwallet->LoadKeyPool(nIndex, keypool);
567561
}
568562
else if (strType == "version")
569563
{

0 commit comments

Comments
 (0)