Skip to content

Commit 191c79c

Browse files
refactor: update thread-safety annotations to use EXCLUSIVE_LOCKS_REQUIRED for various methods in meta store and info
1 parent 41e4324 commit 191c79c

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/masternode/meta.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void CMasternodeMetaInfo::RemoveGovernanceObject(const uint256& nGovernanceObjec
6666
mapGovernanceObjectsVotedOn.erase(nGovernanceObjectHash);
6767
}
6868

69-
CMasternodeMetaInfoPtr CMasternodeMetaMan::GetMetaInfo(const uint256& proTxHash, bool fCreate) LOCKS_EXCLUDED(cs)
69+
CMasternodeMetaInfoPtr CMasternodeMetaMan::GetMetaInfo(const uint256& proTxHash, bool fCreate) EXCLUSIVE_LOCKS_REQUIRED(!cs)
7070
{
7171
LOCK(cs);
7272
auto it = metaInfos.find(proTxHash);
@@ -115,28 +115,28 @@ bool CMasternodeMetaMan::AddGovernanceVote(const uint256& proTxHash, const uint2
115115
return true;
116116
}
117117

118-
void CMasternodeMetaMan::RemoveGovernanceObject(const uint256& nGovernanceObjectHash) LOCKS_EXCLUDED(cs)
118+
void CMasternodeMetaMan::RemoveGovernanceObject(const uint256& nGovernanceObjectHash) EXCLUSIVE_LOCKS_REQUIRED(!cs)
119119
{
120120
LOCK(cs);
121121
for(const auto& p : metaInfos) {
122122
p.second->RemoveGovernanceObject(nGovernanceObjectHash);
123123
}
124124
}
125125

126-
std::vector<uint256> CMasternodeMetaMan::GetAndClearDirtyGovernanceObjectHashes() LOCKS_EXCLUDED(cs)
126+
std::vector<uint256> CMasternodeMetaMan::GetAndClearDirtyGovernanceObjectHashes() EXCLUSIVE_LOCKS_REQUIRED(!cs)
127127
{
128128
std::vector<uint256> vecTmp;
129129
WITH_LOCK(cs, vecTmp.swap(vecDirtyGovernanceObjectHashes));
130130
return vecTmp;
131131
}
132132

133-
bool CMasternodeMetaMan::AlreadyHavePlatformBan(const uint256& inv_hash) const LOCKS_EXCLUDED(cs)
133+
bool CMasternodeMetaMan::AlreadyHavePlatformBan(const uint256& inv_hash) const EXCLUSIVE_LOCKS_REQUIRED(!cs)
134134
{
135135
LOCK(cs);
136136
return m_seen_platform_bans.exists(inv_hash);
137137
}
138138

139-
std::optional<PlatformBanMessage> CMasternodeMetaMan::GetPlatformBan(const uint256& inv_hash) const LOCKS_EXCLUDED(cs)
139+
std::optional<PlatformBanMessage> CMasternodeMetaMan::GetPlatformBan(const uint256& inv_hash) const EXCLUSIVE_LOCKS_REQUIRED(!cs)
140140
{
141141
LOCK(cs);
142142
PlatformBanMessage ret;
@@ -147,13 +147,13 @@ std::optional<PlatformBanMessage> CMasternodeMetaMan::GetPlatformBan(const uint2
147147
return ret;
148148
}
149149

150-
void CMasternodeMetaMan::RememberPlatformBan(const uint256& inv_hash, PlatformBanMessage&& msg) LOCKS_EXCLUDED(cs)
150+
void CMasternodeMetaMan::RememberPlatformBan(const uint256& inv_hash, PlatformBanMessage&& msg) EXCLUSIVE_LOCKS_REQUIRED(!cs)
151151
{
152152
LOCK(cs);
153153
m_seen_platform_bans.insert(inv_hash, std::move(msg));
154154
}
155155

156-
std::string MasternodeMetaStore::ToString() const LOCKS_EXCLUDED(cs)
156+
std::string MasternodeMetaStore::ToString() const EXCLUSIVE_LOCKS_REQUIRED(!cs)
157157
{
158158
LOCK(cs);
159159
return strprintf("Masternodes: meta infos object count: %d, nDsqCount: %d", metaInfos.size(), nDsqCount);

src/masternode/meta.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class MasternodeMetaStore
134134

135135
public:
136136
template<typename Stream>
137-
void Serialize(Stream &s) const LOCKS_EXCLUDED(cs)
137+
void Serialize(Stream &s) const EXCLUSIVE_LOCKS_REQUIRED(!cs)
138138
{
139139
LOCK(cs);
140140
std::vector<CMasternodeMetaInfo> tmpMetaInfo;
@@ -145,7 +145,7 @@ class MasternodeMetaStore
145145
}
146146

147147
template<typename Stream>
148-
void Unserialize(Stream &s) LOCKS_EXCLUDED(cs)
148+
void Unserialize(Stream &s) EXCLUSIVE_LOCKS_REQUIRED(!cs)
149149
{
150150
Clear();
151151

@@ -163,14 +163,14 @@ class MasternodeMetaStore
163163
}
164164
}
165165

166-
void Clear() LOCKS_EXCLUDED(cs)
166+
void Clear() EXCLUSIVE_LOCKS_REQUIRED(!cs)
167167
{
168168
LOCK(cs);
169169

170170
metaInfos.clear();
171171
}
172172

173-
std::string ToString() const LOCKS_EXCLUDED(cs);
173+
std::string ToString() const EXCLUSIVE_LOCKS_REQUIRED(!cs);
174174
};
175175

176176
/**
@@ -233,7 +233,7 @@ class CMasternodeMetaMan : public MasternodeMetaStore
233233

234234
bool IsValid() const { return is_valid; }
235235

236-
CMasternodeMetaInfoPtr GetMetaInfo(const uint256& proTxHash, bool fCreate = true) LOCKS_EXCLUDED(cs);
236+
CMasternodeMetaInfoPtr GetMetaInfo(const uint256& proTxHash, bool fCreate = true) EXCLUSIVE_LOCKS_REQUIRED(!cs);
237237

238238
int64_t GetDsqCount() const { return nDsqCount; }
239239
int64_t GetDsqThreshold(const uint256& proTxHash, int nMnCount);
@@ -242,13 +242,13 @@ class CMasternodeMetaMan : public MasternodeMetaStore
242242
void DisallowMixing(const uint256& proTxHash);
243243

244244
bool AddGovernanceVote(const uint256& proTxHash, const uint256& nGovernanceObjectHash);
245-
void RemoveGovernanceObject(const uint256& nGovernanceObjectHash) LOCKS_EXCLUDED(cs);
245+
void RemoveGovernanceObject(const uint256& nGovernanceObjectHash) EXCLUSIVE_LOCKS_REQUIRED(!cs);
246246

247-
std::vector<uint256> GetAndClearDirtyGovernanceObjectHashes() LOCKS_EXCLUDED(cs);
247+
std::vector<uint256> GetAndClearDirtyGovernanceObjectHashes() EXCLUSIVE_LOCKS_REQUIRED(!cs);
248248

249-
bool AlreadyHavePlatformBan(const uint256& inv_hash) const LOCKS_EXCLUDED(cs);
250-
std::optional<PlatformBanMessage> GetPlatformBan(const uint256& inv_hash) const LOCKS_EXCLUDED(cs);
251-
void RememberPlatformBan(const uint256& inv_hash, PlatformBanMessage&& msg) LOCKS_EXCLUDED(cs);
249+
bool AlreadyHavePlatformBan(const uint256& inv_hash) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
250+
std::optional<PlatformBanMessage> GetPlatformBan(const uint256& inv_hash) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
251+
void RememberPlatformBan(const uint256& inv_hash, PlatformBanMessage&& msg) EXCLUSIVE_LOCKS_REQUIRED(!cs);
252252
};
253253

254254
#endif // BITCOIN_MASTERNODE_META_H

0 commit comments

Comments
 (0)