From 8a7941bd0da106a393abd091472a5902e464c1e3 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Thu, 31 Oct 2024 19:20:40 +0700 Subject: [PATCH 1/3] refactor: merge helper GetCoinbaseTx which is used only once into GetNonNullCoinbaseChainlock --- src/evo/cbtx.cpp | 15 +++++---------- src/evo/cbtx.h | 1 - 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/evo/cbtx.cpp b/src/evo/cbtx.cpp index 48baccd9d9..a9a5abe762 100644 --- a/src/evo/cbtx.cpp +++ b/src/evo/cbtx.cpp @@ -20,6 +20,7 @@ #include #include + bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state) { if (tx.nType != TRANSACTION_COINBASE) { @@ -448,7 +449,7 @@ std::string CCbTx::ToString() const creditPoolBalance / COIN, creditPoolBalance % COIN); } -std::optional GetCoinbaseTx(const CBlockIndex* pindex) +std::optional> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex) { if (pindex == nullptr) { return std::nullopt; @@ -464,20 +465,14 @@ std::optional GetCoinbaseTx(const CBlockIndex* pindex) return std::nullopt; } - CTransactionRef cbTx = block.vtx[0]; - return GetTxPayload(*cbTx); -} - -std::optional> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex) -{ - auto opt_cbtx = GetCoinbaseTx(pindex); + const CTransactionRef cbTx = block.vtx[0]; + const auto opt_cbtx = GetTxPayload(*cbTx); if (!opt_cbtx.has_value()) { return std::nullopt; } - CCbTx& cbtx = opt_cbtx.value(); - + const CCbTx& cbtx = opt_cbtx.value(); if (cbtx.nVersion < CCbTx::Version::CLSIG_AND_BALANCE) { return std::nullopt; } diff --git a/src/evo/cbtx.h b/src/evo/cbtx.h index dccfb56212..cb8ab1f92c 100644 --- a/src/evo/cbtx.h +++ b/src/evo/cbtx.h @@ -100,7 +100,6 @@ bool CheckCbTxBestChainlock(const CBlock& block, const CBlockIndex* pindexPrev, bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_handler, const CBlockIndex* pindexPrev, uint32_t& bestCLHeightDiff, CBLSSignature& bestCLSignature); -std::optional GetCoinbaseTx(const CBlockIndex* pindex); std::optional> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex); #endif // BITCOIN_EVO_CBTX_H From f2a186f3f369581141fce466d4b7db851c053e15 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 4 Nov 2024 14:59:32 +0700 Subject: [PATCH 2/3] refactor: remove definition IsQuorumDKGEnabled from header --- src/llmq/dkgsessionmgr.cpp | 10 +++++----- src/llmq/dkgsessionmgr.h | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/llmq/dkgsessionmgr.cpp b/src/llmq/dkgsessionmgr.cpp index 1743f0376c..04ae1d9166 100644 --- a/src/llmq/dkgsessionmgr.cpp +++ b/src/llmq/dkgsessionmgr.cpp @@ -18,6 +18,11 @@ #include #include +static bool IsQuorumDKGEnabled(const CSporkManager& sporkman) +{ + return sporkman.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED); +} + namespace llmq { static const std::string DB_VVEC = "qdkg_V"; @@ -515,9 +520,4 @@ void CDKGSessionManager::CleanupOldContributions() const } } -bool IsQuorumDKGEnabled(const CSporkManager& sporkman) -{ - return sporkman.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED); -} - } // namespace llmq diff --git a/src/llmq/dkgsessionmgr.h b/src/llmq/dkgsessionmgr.h index 8c1ddea339..1586e1262d 100644 --- a/src/llmq/dkgsessionmgr.h +++ b/src/llmq/dkgsessionmgr.h @@ -104,8 +104,6 @@ private: void MigrateDKG(); void CleanupCache() const; }; - -bool IsQuorumDKGEnabled(const CSporkManager& sporkman); } // namespace llmq #endif // BITCOIN_LLMQ_DKGSESSIONMGR_H From e9387eef69f66bee6419575933022963b2b85fb0 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Fri, 1 Nov 2024 13:36:43 +0700 Subject: [PATCH 3/3] refactor: remove unused includes and forward declarations from headers --- src/evo/assetlocktx.h | 4 ++-- src/evo/creditpool.h | 8 ++++---- src/evo/deterministicmns.h | 1 + src/evo/dmnstate.h | 8 ++++---- src/evo/mnauth.h | 4 ---- src/evo/mnhftx.h | 3 +-- src/evo/providertx.h | 2 -- src/evo/simplifiedmns.h | 8 ++++++-- src/evo/specialtx.h | 1 - src/evo/specialtxman.h | 3 ++- src/llmq/blockprocessor.h | 7 +++---- src/llmq/chainlocks.h | 9 ++++----- src/llmq/commitment.h | 8 ++++++-- src/llmq/context.h | 1 - src/llmq/dkgsession.h | 1 - src/llmq/dkgsessionhandler.h | 13 ++++++++++--- src/llmq/instantsend.h | 8 ++++---- src/llmq/quorums.h | 14 +++++++------- src/llmq/signing.h | 4 ++-- src/llmq/signing_shares.h | 14 +++++++++----- src/llmq/snapshot.h | 8 ++++---- src/masternode/meta.cpp | 1 + src/masternode/meta.h | 7 +++++-- 23 files changed, 75 insertions(+), 62 deletions(-) diff --git a/src/evo/assetlocktx.h b/src/evo/assetlocktx.h index 1e9a666d50..531183fd0a 100644 --- a/src/evo/assetlocktx.h +++ b/src/evo/assetlocktx.h @@ -6,9 +6,9 @@ #define BITCOIN_EVO_ASSETLOCKTX_H #include -#include +#include #include - +#include #include #include diff --git a/src/evo/creditpool.h b/src/evo/creditpool.h index dfb3004f8e..5da980df65 100644 --- a/src/evo/creditpool.h +++ b/src/evo/creditpool.h @@ -5,10 +5,7 @@ #ifndef BITCOIN_EVO_CREDITPOOL_H #define BITCOIN_EVO_CREDITPOOL_H -#include - -#include - +#include #include #include #include @@ -16,10 +13,13 @@ #include #include +#include + #include #include class BlockManager; +class CBlock; class CBlockIndex; class BlockValidationState; class CEvoDB; diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index c8a3020283..52119350f1 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -29,6 +29,7 @@ class CBlock; class CBlockIndex; class CChainState; +class CCoinsViewCache; class CConnman; class CEvoDB; class TxValidationState; diff --git a/src/evo/dmnstate.h b/src/evo/dmnstate.h index 0a0f62316d..acee5c2b49 100644 --- a/src/evo/dmnstate.h +++ b/src/evo/dmnstate.h @@ -5,12 +5,12 @@ #ifndef BITCOIN_EVO_DMNSTATE_H #define BITCOIN_EVO_DMNSTATE_H -#include #include -#include -#include -#include