From 6e31c72e0890cc0f4412d86b93ae96e0a9908aeb Mon Sep 17 00:00:00 2001 From: yanmaani Date: Thu, 27 May 2021 12:00:00 +0000 Subject: [PATCH] Fix CI warnings --- src/miner.cpp | 1 + src/names/main.h | 5 +++-- src/names/mempool.cpp | 16 ++++++++-------- src/names/mempool.h | 1 + src/rest.cpp | 1 + src/txdb.h | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 8aa581c5fc..fab10b1043 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -255,6 +255,7 @@ BlockAssembler::TxAllowedForNamecoin (const CTransaction& tx) const if (nameOutFound && nameOpOut.getNameOp () == OP_NAME_FIRSTUPDATE) { bool nameNewFound = false; + LOCK (cs_main); const auto& coinsTip = ::ChainstateActive ().CoinsTip (); for (const auto& txIn : tx.vin) { diff --git a/src/names/main.h b/src/names/main.h index 060bffe576..a1a13614ac 100644 --- a/src/names/main.h +++ b/src/names/main.h @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -105,7 +106,7 @@ void ApplyNameTransaction (const CTransaction& tx, unsigned nHeight, /** * Expire all names at the given height. This removes their coins * from the UTXO set. - * @param height The new block height. + * @param nHeight The new block height. * @param view The coins view to update. * @param undo The block undo object to record undo information. * @param names List all expired names here. @@ -132,6 +133,6 @@ bool UnexpireNames (unsigned nHeight, CBlockUndo& undo, * this throws an assertion failure. * @param disconnect Whether we are disconnecting blocks. */ -void CheckNameDB (ChainstateManager& chainman, bool disconnect); +void CheckNameDB (ChainstateManager& chainman, bool disconnect) EXCLUSIVE_LOCKS_REQUIRED (cs_main); #endif // H_BITCOIN_NAMES_MAIN diff --git a/src/names/mempool.cpp b/src/names/mempool.cpp index c27060d4dc..5d4be1cc69 100644 --- a/src/names/mempool.cpp +++ b/src/names/mempool.cpp @@ -36,7 +36,7 @@ namespace * there is any. The txid must be for an entry in the mempool. */ COutPoint -getNameOutput (const CTxMemPool& pool, const uint256& txid) +getNameOutput (const CTxMemPool& pool, const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED (pool.cs) { AssertLockHeld (pool.cs); @@ -102,7 +102,7 @@ CNameMemPool::lastNameOutput (const valtype& name) const } void -CNameMemPool::addUnchecked (const CTxMemPoolEntry& entry) +CNameMemPool::addUnchecked (const CTxMemPoolEntry& entry) EXCLUSIVE_LOCKS_REQUIRED (pool.cs) { AssertLockHeld (pool.cs); @@ -137,7 +137,7 @@ CNameMemPool::addUnchecked (const CTxMemPoolEntry& entry) } void -CNameMemPool::remove (const CTxMemPoolEntry& entry) +CNameMemPool::remove (const CTxMemPoolEntry& entry) EXCLUSIVE_LOCKS_REQUIRED (pool.cs) { AssertLockHeld (pool.cs); @@ -162,7 +162,7 @@ CNameMemPool::remove (const CTxMemPoolEntry& entry) } void -CNameMemPool::removeConflicts (const CTransaction& tx) +CNameMemPool::removeConflicts (const CTransaction& tx) EXCLUSIVE_LOCKS_REQUIRED (pool.cs) { AssertLockHeld (pool.cs); @@ -188,7 +188,7 @@ CNameMemPool::removeConflicts (const CTransaction& tx) } void -CNameMemPool::removeUnexpireConflicts (const std::set& unexpired) +CNameMemPool::removeUnexpireConflicts (const std::set& unexpired) EXCLUSIVE_LOCKS_REQUIRED (pool.cs) { AssertLockHeld (pool.cs); @@ -209,7 +209,7 @@ CNameMemPool::removeUnexpireConflicts (const std::set& unexpired) } void -CNameMemPool::removeExpireConflicts (const std::set& expired) +CNameMemPool::removeExpireConflicts (const std::set& expired) EXCLUSIVE_LOCKS_REQUIRED (pool.cs) { AssertLockHeld (pool.cs); @@ -238,7 +238,7 @@ CNameMemPool::removeExpireConflicts (const std::set& expired) } void -CNameMemPool::check (ChainstateManager& chainman, CChainState& active_chainstate) const +CNameMemPool::check (ChainstateManager& chainman, CChainState& active_chainstate) const EXCLUSIVE_LOCKS_REQUIRED (pool.cs) { AssertLockHeld (pool.cs); @@ -309,7 +309,7 @@ CNameMemPool::check (ChainstateManager& chainman, CChainState& active_chainstate } bool -CNameMemPool::checkTx (const CTransaction& tx) const +CNameMemPool::checkTx (const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED (pool.cs) { AssertLockHeld (pool.cs); diff --git a/src/names/mempool.h b/src/names/mempool.h index 7475565489..d753695d05 100644 --- a/src/names/mempool.h +++ b/src/names/mempool.h @@ -147,6 +147,7 @@ class CNameMemPool */ void removeConflicts (const CTransaction& tx); + /** * Removes conflicts in the mempool due to unexpired names. This removes * conflicting name registrations that are no longer possible. diff --git a/src/rest.cpp b/src/rest.cpp index a232de922b..ba4c148adc 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -741,6 +741,7 @@ static bool rest_name(const std::any& context, HTTPRequest* req, const std::stri return RESTERR(req, HTTP_BAD_REQUEST, "Invalid encoded name: " + encodedName); + LOCK (cs_main); CNameData data; if (!::ChainstateActive ().CoinsTip ().GetName(plainName, data)) return RESTERR(req, HTTP_NOT_FOUND, diff --git a/src/txdb.h b/src/txdb.h index 37a1725c3a..b2b74cef86 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -65,7 +65,7 @@ class CCoinsViewDB final : public CCoinsView CNameIterator* IterateNames() const override; bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CNameCache &names) override; CCoinsViewCursor *Cursor() const override; - bool ValidateNameDB(ChainstateManager& chainman, const std::function& interruption_point) const override; + bool ValidateNameDB(ChainstateManager& chainman, const std::function& interruption_point) const override EXCLUSIVE_LOCKS_REQUIRED(cs_main); //! Attempt to update from an older database format. Returns whether an error occurred. bool Upgrade();