Skip to content

Commit 215158a

Browse files
committed
Merge #12785: wallet: Initialize m_last_block_processed to nullptr
f63bc5e wallet: Initialize m_last_block_processed to nullptr. Initialize fields where defined. (practicalswift) Pull request description: Initialize `m_last_block_processed` to `nullptr`. `m_last_block_processed` was introduced in 5ee3172. Tree-SHA512: 6e4a807e5b02115cbd80460761056f2eb22043203212d88dd0cd44c28dc0abce30ab29b078ca2c612232e76af4886f4fdbf2b0ff75e2df19b4d1a801b236cc13
2 parents 83c7533 + f63bc5e commit 215158a

File tree

1 file changed

+15
-34
lines changed

1 file changed

+15
-34
lines changed

src/wallet/wallet.h

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -661,22 +661,22 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
661661
{
662662
private:
663663
static std::atomic<bool> fFlushScheduled;
664-
std::atomic<bool> fAbortRescan;
665-
std::atomic<bool> fScanningWallet; //controlled by WalletRescanReserver
664+
std::atomic<bool> fAbortRescan{false};
665+
std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
666666
std::mutex mutexScanning;
667667
friend class WalletRescanReserver;
668668

669-
CWalletDB *pwalletdbEncryption;
669+
CWalletDB *pwalletdbEncryption = nullptr;
670670

671671
//! the current wallet version: clients below this version are not able to load the wallet
672-
int nWalletVersion;
672+
int nWalletVersion = FEATURE_BASE;
673673

674674
//! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
675-
int nWalletMaxVersion;
675+
int nWalletMaxVersion = FEATURE_BASE;
676676

677-
int64_t nNextResend;
678-
int64_t nLastResend;
679-
bool fBroadcastTransactions;
677+
int64_t nNextResend = 0;
678+
int64_t nLastResend = 0;
679+
bool fBroadcastTransactions = false;
680680

681681
/**
682682
* Used to keep track of spent outpoints, and
@@ -705,10 +705,10 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
705705

706706
std::set<int64_t> setInternalKeyPool;
707707
std::set<int64_t> setExternalKeyPool;
708-
int64_t m_max_keypool_index;
708+
int64_t m_max_keypool_index = 0;
709709
std::map<CKeyID, int64_t> m_pool_key_to_index;
710710

711-
int64_t nTimeFirstKey;
711+
int64_t nTimeFirstKey = 0;
712712

713713
/**
714714
* Private version of AddWatchOnly method which does not accept a
@@ -741,7 +741,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
741741
*
742742
* Protected by cs_main (see BlockUntilSyncedToCurrentChain)
743743
*/
744-
const CBlockIndex* m_last_block_processed;
744+
const CBlockIndex* m_last_block_processed = nullptr;
745745

746746
public:
747747
/*
@@ -780,12 +780,11 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
780780

781781
typedef std::map<unsigned int, CMasterKey> MasterKeyMap;
782782
MasterKeyMap mapMasterKeys;
783-
unsigned int nMasterKeyMaxID;
783+
unsigned int nMasterKeyMaxID = 0;
784784

785785
/** Construct wallet with specified name and database implementation. */
786786
CWallet(std::string name, std::unique_ptr<CWalletDBWrapper> dbw) : m_name(std::move(name)), dbw(std::move(dbw))
787787
{
788-
SetNull();
789788
}
790789

791790
~CWallet()
@@ -794,33 +793,15 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
794793
pwalletdbEncryption = nullptr;
795794
}
796795

797-
void SetNull()
798-
{
799-
nWalletVersion = FEATURE_BASE;
800-
nWalletMaxVersion = FEATURE_BASE;
801-
nMasterKeyMaxID = 0;
802-
pwalletdbEncryption = nullptr;
803-
nOrderPosNext = 0;
804-
nAccountingEntryNumber = 0;
805-
nNextResend = 0;
806-
nLastResend = 0;
807-
m_max_keypool_index = 0;
808-
nTimeFirstKey = 0;
809-
fBroadcastTransactions = false;
810-
nRelockTime = 0;
811-
fAbortRescan = false;
812-
fScanningWallet = false;
813-
}
814-
815796
std::map<uint256, CWalletTx> mapWallet;
816797
std::list<CAccountingEntry> laccentries;
817798

818799
typedef std::pair<CWalletTx*, CAccountingEntry*> TxPair;
819800
typedef std::multimap<int64_t, TxPair > TxItems;
820801
TxItems wtxOrdered;
821802

822-
int64_t nOrderPosNext;
823-
uint64_t nAccountingEntryNumber;
803+
int64_t nOrderPosNext = 0;
804+
uint64_t nAccountingEntryNumber = 0;
824805
std::map<uint256, int> mapRequestCount;
825806

826807
std::map<CTxDestination, CAddressBookData> mapAddressBook;
@@ -913,7 +894,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
913894
bool LoadWatchOnly(const CScript &dest);
914895

915896
//! Holds a timestamp at which point the wallet is scheduled (externally) to be relocked. Caller must arrange for actual relocking to occur via Lock().
916-
int64_t nRelockTime;
897+
int64_t nRelockTime = 0;
917898

918899
bool Unlock(const SecureString& strWalletPassphrase);
919900
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);

0 commit comments

Comments
 (0)