From e86eb71604e73ad35b8b1f59d73af22e353a156e Mon Sep 17 00:00:00 2001 From: Patrick Strateman Date: Mon, 1 Aug 2016 17:14:40 -0700 Subject: Move CWallet::setKeyPool to private section of CWallet --- src/wallet/wallet.h | 15 ++++++++++++++- src/wallet/walletdb.cpp | 10 ++-------- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src/wallet') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 50c94ccfbc..d2e3e2c6e3 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -582,6 +582,8 @@ private: CHDChain hdChain; bool fFileBacked; + + std::set setKeyPool; public: /* * Main wallet lock. @@ -594,7 +596,18 @@ public: std::string strWalletFile; - std::set setKeyPool; + void LoadKeyPool(int nIndex, const CKeyPool &keypool) + { + setKeyPool.insert(nIndex); + + // If no metadata exists yet, create a default with the pool key's + // creation time. Note that this may be overwritten by actually + // stored metadata for that key later, which is fine. + CKeyID keyid = keypool.vchPubKey.GetID(); + if (mapKeyMetadata.count(keyid) == 0) + mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime); + } + std::map mapKeyMetadata; typedef std::map MasterKeyMap; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 543522ca64..025d3606d9 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -556,14 +556,8 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, ssKey >> nIndex; CKeyPool keypool; ssValue >> keypool; - pwallet->setKeyPool.insert(nIndex); - - // If no metadata exists yet, create a default with the pool key's - // creation time. Note that this may be overwritten by actually - // stored metadata for that key later, which is fine. - CKeyID keyid = keypool.vchPubKey.GetID(); - if (pwallet->mapKeyMetadata.count(keyid) == 0) - pwallet->mapKeyMetadata[keyid] = CKeyMetadata(keypool.nTime); + + pwallet->LoadKeyPool(nIndex, keypool); } else if (strType == "version") { -- cgit v1.2.3 From 8680d3aa800aa4fab8c321b92cc7f3fa97a8a0a3 Mon Sep 17 00:00:00 2001 From: Patrick Strateman Date: Fri, 19 Aug 2016 15:50:48 -0700 Subject: Move wallet initialization logic from AppInit2 to CWallet::InitLoadWallet --- src/wallet/wallet.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/wallet') diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ee9254050c..04f08e38c3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3411,7 +3411,17 @@ bool CWallet::InitLoadWallet() } walletInstance->SetBroadcastTransactions(GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST)); + { + LOCK(walletInstance->cs_wallet); + LogPrintf("setKeyPool.size() = %u\n", walletInstance->GetKeyPoolSize()); + LogPrintf("mapWallet.size() = %u\n", walletInstance->mapWallet.size()); + LogPrintf("mapAddressBook.size() = %u\n", walletInstance->mapAddressBook.size()); + } + // Add wallet transactions that aren't already in a block to mapTransactions + walletInstance->ReacceptWalletTransactions(); + pwalletMain = walletInstance; + return true; } -- cgit v1.2.3