From f63bc5e06310ea25051e2bf89c231f6096dda169 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Mon, 26 Mar 2018 10:52:32 +0200 Subject: [PATCH] wallet: Initialize m_last_block_processed to nullptr. Initialize fields where defined. --- src/wallet/wallet.h | 49 ++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 3ef5bfbb65..3a025a8de9 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -660,22 +660,22 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface { private: static std::atomic fFlushScheduled; - std::atomic fAbortRescan; - std::atomic fScanningWallet; //controlled by WalletRescanReserver + std::atomic fAbortRescan{false}; + std::atomic fScanningWallet{false}; // controlled by WalletRescanReserver std::mutex mutexScanning; friend class WalletRescanReserver; - CWalletDB *pwalletdbEncryption; + CWalletDB *pwalletdbEncryption = nullptr; //! 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 - int nWalletMaxVersion; + int nWalletMaxVersion = FEATURE_BASE; - int64_t nNextResend; - int64_t nLastResend; - bool fBroadcastTransactions; + int64_t nNextResend = 0; + int64_t nLastResend = 0; + bool fBroadcastTransactions = false; /** * Used to keep track of spent outpoints, and @@ -704,10 +704,10 @@ private: std::set setInternalKeyPool; std::set setExternalKeyPool; - int64_t m_max_keypool_index; + int64_t m_max_keypool_index = 0; std::map m_pool_key_to_index; - int64_t nTimeFirstKey; + int64_t nTimeFirstKey = 0; /** * Private version of AddWatchOnly method which does not accept a @@ -740,7 +740,7 @@ private: * * Protected by cs_main (see BlockUntilSyncedToCurrentChain) */ - const CBlockIndex* m_last_block_processed; + const CBlockIndex* m_last_block_processed = nullptr; public: /* @@ -779,12 +779,11 @@ public: typedef std::map MasterKeyMap; MasterKeyMap mapMasterKeys; - unsigned int nMasterKeyMaxID; + unsigned int nMasterKeyMaxID = 0; /** Construct wallet with specified name and database implementation. */ CWallet(std::string name, std::unique_ptr dbw) : m_name(std::move(name)), dbw(std::move(dbw)) { - SetNull(); } ~CWallet() @@ -793,24 +792,6 @@ public: 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 mapWallet; std::list laccentries; @@ -818,8 +799,8 @@ public: typedef std::multimap TxItems; TxItems wtxOrdered; - int64_t nOrderPosNext; - uint64_t nAccountingEntryNumber; + int64_t nOrderPosNext = 0; + uint64_t nAccountingEntryNumber = 0; std::map mapRequestCount; std::map mapAddressBook; @@ -912,7 +893,7 @@ public: 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(). - int64_t nRelockTime; + int64_t nRelockTime = 0; bool Unlock(const SecureString& strWalletPassphrase); bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);