Skip to content

Commit

Permalink
spork: replace LOCKS_EXCLUDED with negative EXCLUSIVE_LOCKS_REQUIRED
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Apr 30, 2024
1 parent d657951 commit 0bba55f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/spork.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class SporkStore

public:
template<typename Stream>
void Serialize(Stream &s) const LOCKS_EXCLUDED(cs)
void Serialize(Stream &s) const EXCLUSIVE_LOCKS_REQUIRED(!cs)
{
// We don't serialize pubkey ids because pubkeys should be
// hardcoded or be set with cmdline or options, should
Expand All @@ -182,7 +182,7 @@ class SporkStore
}

template<typename Stream>
void Unserialize(Stream &s) LOCKS_EXCLUDED(cs)
void Unserialize(Stream &s) EXCLUSIVE_LOCKS_REQUIRED(!cs)
{
LOCK(cs);
std::string strVersion;
Expand All @@ -199,12 +199,12 @@ class SporkStore
*
* This method was introduced along with the spork cache.
*/
void Clear() LOCKS_EXCLUDED(cs);
void Clear() EXCLUSIVE_LOCKS_REQUIRED(!cs);

/**
* ToString returns the string representation of the SporkManager.
*/
std::string ToString() const LOCKS_EXCLUDED(cs);
std::string ToString() const EXCLUSIVE_LOCKS_REQUIRED(!cs);
};

/**
Expand Down Expand Up @@ -253,7 +253,7 @@ class CSporkManager : public SporkStore
*
* This method was introduced along with the spork cache.
*/
void CheckAndRemove() LOCKS_EXCLUDED(cs);
void CheckAndRemove() EXCLUSIVE_LOCKS_REQUIRED(!cs);

/**
* ProcessMessage is used to call ProcessSpork and ProcessGetSporks. See below
Expand All @@ -266,20 +266,20 @@ class CSporkManager : public SporkStore
* For 'spork', it validates the spork and adds it to the internal spork storage and
* performs any necessary processing.
*/
PeerMsgRet ProcessSpork(const CNode& peer, PeerManager& peerman, CDataStream& vRecv) LOCKS_EXCLUDED(cs);
PeerMsgRet ProcessSpork(const CNode& peer, PeerManager& peerman, CDataStream& vRecv) EXCLUSIVE_LOCKS_REQUIRED(!cs);

/**
* ProcessGetSporks is used to handle the 'getsporks' p2p message.
*
* For 'getsporks', it sends active sporks to the requesting peer.
*/
void ProcessGetSporks(CNode& peer, CConnman& connman) LOCKS_EXCLUDED(cs);
void ProcessGetSporks(CNode& peer, CConnman& connman) EXCLUSIVE_LOCKS_REQUIRED(!cs);

/**
* UpdateSpork is used by the spork RPC command to set a new spork value, sign
* and broadcast the spork message.
*/
bool UpdateSpork(PeerManager& peerman, SporkId nSporkID, SporkValue nValue) LOCKS_EXCLUDED(cs);
bool UpdateSpork(PeerManager& peerman, SporkId nSporkID, SporkValue nValue) EXCLUSIVE_LOCKS_REQUIRED(!cs);

/**
* IsSporkActive returns a bool for time-based sporks, and should be used
Expand All @@ -295,7 +295,7 @@ class CSporkManager : public SporkStore
* GetSporkValue returns the spork value given a Spork ID. If no active spork
* message has yet been received by the node, it returns the default value.
*/
SporkValue GetSporkValue(SporkId nSporkID) const LOCKS_EXCLUDED(cs);
SporkValue GetSporkValue(SporkId nSporkID) const EXCLUSIVE_LOCKS_REQUIRED(!cs);

/**
* GetSporkIDByName returns the internal Spork ID given the spork name.
Expand All @@ -310,7 +310,7 @@ class CSporkManager : public SporkStore
* hash-based index of sporks for this reason, and this function is the access
* point into that index.
*/
std::optional<CSporkMessage> GetSporkByHash(const uint256& hash) const LOCKS_EXCLUDED(cs);
std::optional<CSporkMessage> GetSporkByHash(const uint256& hash) const EXCLUSIVE_LOCKS_REQUIRED(!cs);

/**
* SetSporkAddress is used to set a public key ID which will be used to
Expand All @@ -319,7 +319,7 @@ class CSporkManager : public SporkStore
* This can be called multiple times to add multiple keys to the set of
* valid spork signers.
*/
bool SetSporkAddress(const std::string& strAddress) LOCKS_EXCLUDED(cs);
bool SetSporkAddress(const std::string& strAddress) EXCLUSIVE_LOCKS_REQUIRED(!cs);

/**
* SetMinSporkKeys is used to set the required spork signer threshold, for
Expand All @@ -328,7 +328,7 @@ class CSporkManager : public SporkStore
* This value must be at least a majority of the total number of spork
* keys, and for obvious reasons cannot be larger than that number.
*/
bool SetMinSporkKeys(int minSporkKeys) LOCKS_EXCLUDED(cs);
bool SetMinSporkKeys(int minSporkKeys) EXCLUSIVE_LOCKS_REQUIRED(!cs);

/**
* SetPrivKey is used to set a spork key to enable setting / signing of
Expand All @@ -337,7 +337,7 @@ class CSporkManager : public SporkStore
* This will return false if the private key does not match any spork
* address in the set of valid spork signers (see SetSporkAddress).
*/
bool SetPrivKey(const std::string& strPrivKey) LOCKS_EXCLUDED(cs);
bool SetPrivKey(const std::string& strPrivKey) EXCLUSIVE_LOCKS_REQUIRED(!cs);
};

#endif // BITCOIN_SPORK_H

0 comments on commit 0bba55f

Please sign in to comment.