Skip to content

Commit e5cefb9

Browse files
committed
Added locks on the setpwalletRegistered functions in main.cpp and added an UnregisterAllWallets function.
1 parent 79f6925 commit e5cefb9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,16 @@ void UnregisterWallet(CWallet* pwalletIn)
9999
}
100100
}
101101

102+
void UnregisterAllWallets()
103+
{
104+
LOCK(cs_setpwalletRegistered);
105+
setpwalletRegistered.clear();
106+
}
107+
102108
// get the wallet transaction with the given hash (if it exists)
103109
bool static GetTransaction(const uint256& hashTx, CWalletTx& wtx)
104110
{
111+
LOCK(cs_setpwalletRegistered);
105112
BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
106113
if (pwallet->GetTransaction(hashTx,wtx))
107114
return true;
@@ -111,48 +118,55 @@ bool static GetTransaction(const uint256& hashTx, CWalletTx& wtx)
111118
// erases transaction with the given hash from all wallets
112119
void static EraseFromWallets(uint256 hash)
113120
{
121+
LOCK(cs_setpwalletRegistered);
114122
BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
115123
pwallet->EraseFromWallet(hash);
116124
}
117125

118126
// make sure all wallets know about the given transaction, in the given block
119127
void SyncWithWallets(const uint256 &hash, const CTransaction& tx, const CBlock* pblock, bool fUpdate)
120128
{
129+
LOCK(cs_setpwalletRegistered);
121130
BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
122131
pwallet->AddToWalletIfInvolvingMe(hash, tx, pblock, fUpdate);
123132
}
124133

125134
// notify wallets about a new best chain
126135
void static SetBestChain(const CBlockLocator& loc)
127136
{
137+
LOCK(cs_setpwalletRegistered);
128138
BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
129139
pwallet->SetBestChain(loc);
130140
}
131141

132142
// notify wallets about an updated transaction
133143
void static UpdatedTransaction(const uint256& hashTx)
134144
{
145+
LOCK(cs_setpwalletRegistered);
135146
BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
136147
pwallet->UpdatedTransaction(hashTx);
137148
}
138149

139150
// dump all wallets
140151
void static PrintWallets(const CBlock& block)
141152
{
153+
LOCK(cs_setpwalletRegistered);
142154
BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
143155
pwallet->PrintWallet(block);
144156
}
145157

146158
// notify wallets about an incoming inventory (for request counts)
147159
void static Inventory(const uint256& hash)
148160
{
161+
LOCK(cs_setpwalletRegistered);
149162
BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
150163
pwallet->Inventory(hash);
151164
}
152165

153166
// ask wallets to resend their transactions
154167
void static ResendWalletTransactions()
155168
{
169+
LOCK(cs_setpwalletRegistered);
156170
BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
157171
pwallet->ResendWalletTransactions();
158172
}

0 commit comments

Comments
 (0)