wallet: Initialize m_last_block_processed to nullptr. Initialize fields where defined.

This commit is contained in:
practicalswift 2018-03-26 10:52:32 +02:00
parent c564424d98
commit f63bc5e063

View File

@ -660,22 +660,22 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
{ {
private: private:
static std::atomic<bool> fFlushScheduled; static std::atomic<bool> fFlushScheduled;
std::atomic<bool> fAbortRescan; std::atomic<bool> fAbortRescan{false};
std::atomic<bool> fScanningWallet; //controlled by WalletRescanReserver std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
std::mutex mutexScanning; std::mutex mutexScanning;
friend class WalletRescanReserver; friend class WalletRescanReserver;
CWalletDB *pwalletdbEncryption; CWalletDB *pwalletdbEncryption = nullptr;
//! the current wallet version: clients below this version are not able to load the wallet //! the current wallet version: clients below this version are not able to load the wallet
int nWalletVersion; int nWalletVersion = FEATURE_BASE;
//! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded //! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
int nWalletMaxVersion; int nWalletMaxVersion = FEATURE_BASE;
int64_t nNextResend; int64_t nNextResend = 0;
int64_t nLastResend; int64_t nLastResend = 0;
bool fBroadcastTransactions; bool fBroadcastTransactions = false;
/** /**
* Used to keep track of spent outpoints, and * Used to keep track of spent outpoints, and
@ -704,10 +704,10 @@ private:
std::set<int64_t> setInternalKeyPool; std::set<int64_t> setInternalKeyPool;
std::set<int64_t> setExternalKeyPool; std::set<int64_t> setExternalKeyPool;
int64_t m_max_keypool_index; int64_t m_max_keypool_index = 0;
std::map<CKeyID, int64_t> m_pool_key_to_index; std::map<CKeyID, int64_t> m_pool_key_to_index;
int64_t nTimeFirstKey; int64_t nTimeFirstKey = 0;
/** /**
* Private version of AddWatchOnly method which does not accept a * Private version of AddWatchOnly method which does not accept a
@ -740,7 +740,7 @@ private:
* *
* Protected by cs_main (see BlockUntilSyncedToCurrentChain) * Protected by cs_main (see BlockUntilSyncedToCurrentChain)
*/ */
const CBlockIndex* m_last_block_processed; const CBlockIndex* m_last_block_processed = nullptr;
public: public:
/* /*
@ -779,12 +779,11 @@ public:
typedef std::map<unsigned int, CMasterKey> MasterKeyMap; typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
MasterKeyMap mapMasterKeys; MasterKeyMap mapMasterKeys;
unsigned int nMasterKeyMaxID; unsigned int nMasterKeyMaxID = 0;
/** Construct wallet with specified name and database implementation. */ /** Construct wallet with specified name and database implementation. */
CWallet(std::string name, std::unique_ptr<CWalletDBWrapper> dbw) : m_name(std::move(name)), dbw(std::move(dbw)) CWallet(std::string name, std::unique_ptr<CWalletDBWrapper> dbw) : m_name(std::move(name)), dbw(std::move(dbw))
{ {
SetNull();
} }
~CWallet() ~CWallet()
@ -793,24 +792,6 @@ public:
pwalletdbEncryption = nullptr; pwalletdbEncryption = nullptr;
} }
void SetNull()
{
nWalletVersion = FEATURE_BASE;
nWalletMaxVersion = FEATURE_BASE;
nMasterKeyMaxID = 0;
pwalletdbEncryption = nullptr;
nOrderPosNext = 0;
nAccountingEntryNumber = 0;
nNextResend = 0;
nLastResend = 0;
m_max_keypool_index = 0;
nTimeFirstKey = 0;
fBroadcastTransactions = false;
nRelockTime = 0;
fAbortRescan = false;
fScanningWallet = false;
}
std::map<uint256, CWalletTx> mapWallet; std::map<uint256, CWalletTx> mapWallet;
std::list<CAccountingEntry> laccentries; std::list<CAccountingEntry> laccentries;
@ -818,8 +799,8 @@ public:
typedef std::multimap<int64_t, TxPair > TxItems; typedef std::multimap<int64_t, TxPair > TxItems;
TxItems wtxOrdered; TxItems wtxOrdered;
int64_t nOrderPosNext; int64_t nOrderPosNext = 0;
uint64_t nAccountingEntryNumber; uint64_t nAccountingEntryNumber = 0;
std::map<uint256, int> mapRequestCount; std::map<uint256, int> mapRequestCount;
std::map<CTxDestination, CAddressBookData> mapAddressBook; std::map<CTxDestination, CAddressBookData> mapAddressBook;
@ -912,7 +893,7 @@ public:
bool LoadWatchOnly(const CScript &dest); bool LoadWatchOnly(const CScript &dest);
//! Holds a timestamp at which point the wallet is scheduled (externally) to be relocked. Caller must arrange for actual relocking to occur via Lock(). //! Holds a timestamp at which point the wallet is scheduled (externally) to be relocked. Caller must arrange for actual relocking to occur via Lock().
int64_t nRelockTime; int64_t nRelockTime = 0;
bool Unlock(const SecureString& strWalletPassphrase); bool Unlock(const SecureString& strWalletPassphrase);
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase); bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);