masternode: replace LOCKS_EXCLUDED with negative EXCLUSIVE_LOCKS_REQUIRED

This commit is contained in:
Kittywhiskers Van Gogh 2024-04-30 10:36:54 +00:00
parent 8b1d3b55ab
commit d657951f90
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD
4 changed files with 24 additions and 23 deletions

View File

@ -603,21 +603,21 @@ public:
~CDeterministicMNManager() = default; ~CDeterministicMNManager() = default;
bool ProcessBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindex, BlockValidationState& state, bool ProcessBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindex, BlockValidationState& state,
const CCoinsViewCache& view, bool fJustCheck, std::optional<MNListUpdates>& updatesRet) EXCLUSIVE_LOCKS_REQUIRED(cs_main) LOCKS_EXCLUDED(cs); const CCoinsViewCache& view, bool fJustCheck, std::optional<MNListUpdates>& updatesRet) EXCLUSIVE_LOCKS_REQUIRED(!cs, cs_main);
bool UndoBlock(gsl::not_null<const CBlockIndex*> pindex, std::optional<MNListUpdates>& updatesRet) LOCKS_EXCLUDED(cs); bool UndoBlock(gsl::not_null<const CBlockIndex*> pindex, std::optional<MNListUpdates>& updatesRet) EXCLUSIVE_LOCKS_REQUIRED(!cs);
void UpdatedBlockTip(gsl::not_null<const CBlockIndex*> pindex) LOCKS_EXCLUDED(cs); void UpdatedBlockTip(gsl::not_null<const CBlockIndex*> pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs);
// the returned list will not contain the correct block hash (we can't know it yet as the coinbase TX is not updated yet) // the returned list will not contain the correct block hash (we can't know it yet as the coinbase TX is not updated yet)
bool BuildNewListFromBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindexPrev, BlockValidationState& state, const CCoinsViewCache& view, bool BuildNewListFromBlock(const CBlock& block, gsl::not_null<const CBlockIndex*> pindexPrev, BlockValidationState& state, const CCoinsViewCache& view,
CDeterministicMNList& mnListRet, bool debugLogs) LOCKS_EXCLUDED(cs); CDeterministicMNList& mnListRet, bool debugLogs) EXCLUSIVE_LOCKS_REQUIRED(!cs);
void HandleQuorumCommitment(const llmq::CFinalCommitment& qc, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, CDeterministicMNList& mnList, bool debugLogs); void HandleQuorumCommitment(const llmq::CFinalCommitment& qc, gsl::not_null<const CBlockIndex*> pQuorumBaseBlockIndex, CDeterministicMNList& mnList, bool debugLogs);
CDeterministicMNList GetListForBlock(gsl::not_null<const CBlockIndex*> pindex) LOCKS_EXCLUDED(cs) { CDeterministicMNList GetListForBlock(gsl::not_null<const CBlockIndex*> pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs) {
LOCK(cs); LOCK(cs);
return GetListForBlockInternal(pindex); return GetListForBlockInternal(pindex);
}; };
CDeterministicMNList GetListAtChainTip() LOCKS_EXCLUDED(cs); CDeterministicMNList GetListAtChainTip() EXCLUSIVE_LOCKS_REQUIRED(!cs);
// Test if given TX is a ProRegTx which also contains the collateral at index n // Test if given TX is a ProRegTx which also contains the collateral at index n
static bool IsProTxWithCollateral(const CTransactionRef& tx, uint32_t n); static bool IsProTxWithCollateral(const CTransactionRef& tx, uint32_t n);
@ -625,7 +625,7 @@ public:
bool MigrateDBIfNeeded(); bool MigrateDBIfNeeded();
bool MigrateDBIfNeeded2(); bool MigrateDBIfNeeded2();
void DoMaintenance() LOCKS_EXCLUDED(cs); void DoMaintenance() EXCLUSIVE_LOCKS_REQUIRED(!cs);
private: private:
void CleanupCache(int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs); void CleanupCache(int nHeight) EXCLUSIVE_LOCKS_REQUIRED(cs);

View File

@ -48,7 +48,7 @@ private:
public: public:
explicit CEvoDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); explicit CEvoDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
std::unique_ptr<CEvoDBScopedCommitter> BeginTransaction() LOCKS_EXCLUDED(cs) std::unique_ptr<CEvoDBScopedCommitter> BeginTransaction() EXCLUSIVE_LOCKS_REQUIRED(!cs)
{ {
LOCK(cs); LOCK(cs);
return std::make_unique<CEvoDBScopedCommitter>(*this); return std::make_unique<CEvoDBScopedCommitter>(*this);
@ -61,28 +61,28 @@ public:
} }
template <typename K, typename V> template <typename K, typename V>
bool Read(const K& key, V& value) LOCKS_EXCLUDED(cs) bool Read(const K& key, V& value) EXCLUSIVE_LOCKS_REQUIRED(!cs)
{ {
LOCK(cs); LOCK(cs);
return curDBTransaction.Read(key, value); return curDBTransaction.Read(key, value);
} }
template <typename K, typename V> template <typename K, typename V>
void Write(const K& key, const V& value) LOCKS_EXCLUDED(cs) void Write(const K& key, const V& value) EXCLUSIVE_LOCKS_REQUIRED(!cs)
{ {
LOCK(cs); LOCK(cs);
curDBTransaction.Write(key, value); curDBTransaction.Write(key, value);
} }
template <typename K> template <typename K>
bool Exists(const K& key) LOCKS_EXCLUDED(cs) bool Exists(const K& key) EXCLUSIVE_LOCKS_REQUIRED(!cs)
{ {
LOCK(cs); LOCK(cs);
return curDBTransaction.Exists(key); return curDBTransaction.Exists(key);
} }
template <typename K> template <typename K>
void Erase(const K& key) LOCKS_EXCLUDED(cs) void Erase(const K& key) EXCLUSIVE_LOCKS_REQUIRED(!cs)
{ {
LOCK(cs); LOCK(cs);
curDBTransaction.Erase(key); curDBTransaction.Erase(key);
@ -98,18 +98,18 @@ public:
return rootDBTransaction.GetMemoryUsage(); return rootDBTransaction.GetMemoryUsage();
} }
bool CommitRootTransaction() LOCKS_EXCLUDED(cs); bool CommitRootTransaction() EXCLUSIVE_LOCKS_REQUIRED(!cs);
bool IsEmpty() { return db.IsEmpty(); } bool IsEmpty() { return db.IsEmpty(); }
bool VerifyBestBlock(const uint256& hash); bool VerifyBestBlock(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(!cs);
void WriteBestBlock(const uint256& hash); void WriteBestBlock(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(!cs);
private: private:
// only CEvoDBScopedCommitter is allowed to invoke these // only CEvoDBScopedCommitter is allowed to invoke these
friend class CEvoDBScopedCommitter; friend class CEvoDBScopedCommitter;
void CommitCurTransaction() LOCKS_EXCLUDED(cs); void CommitCurTransaction() EXCLUSIVE_LOCKS_REQUIRED(!cs);
void RollbackCurTransaction() LOCKS_EXCLUDED(cs); void RollbackCurTransaction() EXCLUSIVE_LOCKS_REQUIRED(!cs);
}; };
#endif // BITCOIN_EVO_EVODB_H #endif // BITCOIN_EVO_EVODB_H

View File

@ -128,7 +128,7 @@ public:
/** /**
* Helper that used in Unit Test to forcely setup EHF signal for specific block * Helper that used in Unit Test to forcely setup EHF signal for specific block
*/ */
void AddSignal(const CBlockIndex* const pindex, int bit) LOCKS_EXCLUDED(cs_cache); void AddSignal(const CBlockIndex* const pindex, int bit) EXCLUSIVE_LOCKS_REQUIRED(!cs_cache);
private: private:
void AddToCache(const Signals& signals, const CBlockIndex* const pindex); void AddToCache(const Signals& signals, const CBlockIndex* const pindex);

View File

@ -53,9 +53,10 @@ private:
public: public:
explicit CActiveMasternodeManager(const CBLSSecretKey& sk, CConnman& connman, const std::unique_ptr<CDeterministicMNManager>& dmnman); explicit CActiveMasternodeManager(const CBLSSecretKey& sk, CConnman& connman, const std::unique_ptr<CDeterministicMNManager>& dmnman);
void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override; void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) override
EXCLUSIVE_LOCKS_REQUIRED(!cs);
void Init(const CBlockIndex* pindex) LOCKS_EXCLUDED(cs) { LOCK(cs); InitInternal(pindex); }; void Init(const CBlockIndex* pindex) EXCLUSIVE_LOCKS_REQUIRED(!cs) { LOCK(cs); InitInternal(pindex); };
std::string GetStateString() const; std::string GetStateString() const;
std::string GetStatus() const; std::string GetStatus() const;
@ -64,9 +65,9 @@ public:
template <template <typename> class EncryptedObj, typename Obj> template <template <typename> class EncryptedObj, typename Obj>
[[nodiscard]] bool Decrypt(const EncryptedObj<Obj>& obj, size_t idx, Obj& ret_obj, int version) const [[nodiscard]] bool Decrypt(const EncryptedObj<Obj>& obj, size_t idx, Obj& ret_obj, int version) const
LOCKS_EXCLUDED(cs); EXCLUSIVE_LOCKS_REQUIRED(!cs);
[[nodiscard]] CBLSSignature Sign(const uint256& hash) const LOCKS_EXCLUDED(cs); [[nodiscard]] CBLSSignature Sign(const uint256& hash) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
[[nodiscard]] CBLSSignature Sign(const uint256& hash, const bool is_legacy) const LOCKS_EXCLUDED(cs); [[nodiscard]] CBLSSignature Sign(const uint256& hash, const bool is_legacy) const EXCLUSIVE_LOCKS_REQUIRED(!cs);
/* TODO: Reconsider external locking */ /* TODO: Reconsider external locking */
[[nodiscard]] COutPoint GetOutPoint() const { READ_LOCK(cs); return m_info.outpoint; } [[nodiscard]] COutPoint GetOutPoint() const { READ_LOCK(cs); return m_info.outpoint; }