Skip to content

Commit 37b2538

Browse files
Add GUARDED_BY(cs_wallet) for encrypted_batch, nWalletMaxVersion, m_max_keypool_index and nOrderPosNext
* AddKeyPubKeyWithDB(...) reads encrypted_batch which potentially races with write in the same method. * IncOrderPosNext(...) reads nOrderPosNext which potentially races with write in BlockDisconnected(...). * LoadKeyPool(...) reads m_max_keypool_index which potentially races with write in BlockDisconnected(...). * LoadMinVersion(...) reads nWalletMaxVersion which potentially races with write in BlockDisconnected(...).
1 parent dee4292 commit 37b2538

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/wallet/wallet.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,13 +601,13 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
601601
std::mutex mutexScanning;
602602
friend class WalletRescanReserver;
603603

604-
WalletBatch *encrypted_batch = nullptr;
604+
WalletBatch *encrypted_batch GUARDED_BY(cs_wallet) = nullptr;
605605

606606
//! the current wallet version: clients below this version are not able to load the wallet
607607
int nWalletVersion = FEATURE_BASE;
608608

609609
//! the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded
610-
int nWalletMaxVersion = FEATURE_BASE;
610+
int nWalletMaxVersion GUARDED_BY(cs_wallet) = FEATURE_BASE;
611611

612612
int64_t nNextResend = 0;
613613
int64_t nLastResend = 0;
@@ -659,7 +659,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
659659
std::set<int64_t> setInternalKeyPool;
660660
std::set<int64_t> setExternalKeyPool;
661661
std::set<int64_t> set_pre_split_keypool;
662-
int64_t m_max_keypool_index = 0;
662+
int64_t m_max_keypool_index GUARDED_BY(cs_wallet) = 0;
663663
std::map<CKeyID, int64_t> m_pool_key_to_index;
664664
std::atomic<uint64_t> m_wallet_flags{0};
665665

@@ -754,7 +754,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
754754
typedef std::multimap<int64_t, CWalletTx*> TxItems;
755755
TxItems wtxOrdered;
756756

757-
int64_t nOrderPosNext = 0;
757+
int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0;
758758
uint64_t nAccountingEntryNumber = 0;
759759

760760
std::map<CTxDestination, CAddressBookData> mapAddressBook;

0 commit comments

Comments
 (0)