From 31b97367c7da326c4c4c81c0fef542fd355b0f52 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Tue, 29 Nov 2022 21:18:53 +0700 Subject: [PATCH] Satisfy linter: added circular dependency, missing const, fixed usage of macros GUARDED_BY --- src/evo/assetlocktx.cpp | 2 +- src/evo/creditpool.cpp | 5 ----- src/evo/creditpool.h | 3 ++- test/lint/lint-circular-dependencies.sh | 2 ++ 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/evo/assetlocktx.cpp b/src/evo/assetlocktx.cpp index 9be8cc1fb083cb..5fa31d0be8b4e7 100644 --- a/src/evo/assetlocktx.cpp +++ b/src/evo/assetlocktx.cpp @@ -132,7 +132,7 @@ maybe_error CAssetUnlockPayload::VerifySig(const uint256& msgHash, const CBlockI // TODO: update it after choosing proper consensus.llmqTypeAssetLocks (see comment there) const int count = 2; auto quorums = llmq::quorumManager->ScanQuorums(llmqType, pindexTip, count > -1 ? count : llmq_params.signingActiveQuorumCount); - bool isActive = std::any_of(quorums.begin(), quorums.end(), [&](auto &q) { return q->qc->quorumHash == quorumHash; }); + bool isActive = std::any_of(quorums.begin(), quorums.end(), [&](const auto &q) { return q->qc->quorumHash == quorumHash; }); if (!isActive) { return {ValidationInvalidReason::CONSENSUS, "bad-assetunlock-not-active-quorum"}; diff --git a/src/evo/creditpool.cpp b/src/evo/creditpool.cpp index b9f245d30a457f..0fff43c40ef22a 100644 --- a/src/evo/creditpool.cpp +++ b/src/evo/creditpool.cpp @@ -39,11 +39,6 @@ static bool getAmountToUnlock(const CTransaction& tx, CAmount& toUnlock, int64_t return true; } -namespace { -CCriticalSection cs_cache; - -} // anonymous namespace - std::optional CCreditPoolManager::getFromCache(const uint256& block_hash, int height) { LOCK(cs_cache); CreditPoolCb pool{0, 0, {}}; diff --git a/src/evo/creditpool.h b/src/evo/creditpool.h index e77ab53c37dbb0..979412cdc5e816 100644 --- a/src/evo/creditpool.h +++ b/src/evo/creditpool.h @@ -110,7 +110,8 @@ class CCreditPoolManager { private: static constexpr size_t CreditPoolCacheSize = 1000; - unordered_lru_cache creditPoolCache{CreditPoolCacheSize} GUARDED_BY(cs_cache); + CCriticalSection cs_cache; + unordered_lru_cache creditPoolCache GUARDED_BY(cs_cache) {CreditPoolCacheSize}; CEvoDB& evoDb; diff --git a/test/lint/lint-circular-dependencies.sh b/test/lint/lint-circular-dependencies.sh index 75219d4254784b..f2c81c55e5f233 100755 --- a/test/lint/lint-circular-dependencies.sh +++ b/test/lint/lint-circular-dependencies.sh @@ -81,6 +81,8 @@ EXPECTED_CIRCULAR_DEPENDENCIES=( "evo/specialtxman -> validation -> evo/specialtxman" "consensus/tx_verify -> evo/assetlocktx -> validation -> consensus/tx_verify" "consensus/tx_verify -> evo/assetlocktx -> llmq/quorums -> net_processing -> txmempool -> consensus/tx_verify" + "evo/assetlocktx -> evo/creditpool -> evo/assetlocktx" + "evo/assetlocktx -> llmq/quorums -> net_processing -> txmempool -> evo/assetlocktx" "evo/simplifiedmns -> llmq/blockprocessor -> net_processing -> llmq/snapshot -> evo/simplifiedmns" "llmq/blockprocessor -> net_processing -> llmq/context -> llmq/blockprocessor"