Skip to content

Commit 3aa51d6

Browse files
Merge #6376: refactor: a bunch of trivial-ish headers improvements
e9387ee refactor: remove unused includes and forward declarations from headers (Konstantin Akimov) f2a186f refactor: remove definition IsQuorumDKGEnabled from header (Konstantin Akimov) 8a7941b refactor: merge helper GetCoinbaseTx which is used only once into GetNonNullCoinbaseChainlock (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented Split from #6375 and added some extra ## What was done? Tidy up headers of evo/ and llmq/: - removed unused includes and added missing - removed unused forward declarations and added missing - removed helper GetCoinbaseTx, moved helper IsQuorumDKGEnabled from header to implementation ## How Has This Been Tested? Run unit and functional tests Compilation time _in theory_ should be improved, in really it shaved just 2-5 seconds from 5 minutes by my benchmark. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [x] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK e9387ee PastaPastaPasta: utACK e9387ee Tree-SHA512: 7b4795fe0bcea23b9f368a962b888d610cac94b42dd6419cfe06977c1a28bbe27a7a2ae2e4cd730ec0ca4f8b333f656a601ebb90bc271f4117dec7a424a08b45
2 parents b12f5f5 + e9387ee commit 3aa51d6

27 files changed

+84
-79
lines changed

src/evo/assetlocktx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#define BITCOIN_EVO_ASSETLOCKTX_H
77

88
#include <bls/bls_ies.h>
9-
#include <primitives/transaction.h>
9+
#include <consensus/amount.h>
1010
#include <gsl/pointers.h>
11-
11+
#include <primitives/transaction.h>
1212
#include <serialize.h>
1313
#include <univalue.h>
1414

src/evo/cbtx.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <deploymentstatus.h>
2121
#include <validation.h>
2222

23+
2324
bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state)
2425
{
2526
if (tx.nType != TRANSACTION_COINBASE) {
@@ -448,7 +449,7 @@ std::string CCbTx::ToString() const
448449
creditPoolBalance / COIN, creditPoolBalance % COIN);
449450
}
450451

451-
std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex)
452+
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex)
452453
{
453454
if (pindex == nullptr) {
454455
return std::nullopt;
@@ -464,20 +465,14 @@ std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex)
464465
return std::nullopt;
465466
}
466467

467-
CTransactionRef cbTx = block.vtx[0];
468-
return GetTxPayload<CCbTx>(*cbTx);
469-
}
470-
471-
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex)
472-
{
473-
auto opt_cbtx = GetCoinbaseTx(pindex);
468+
const CTransactionRef cbTx = block.vtx[0];
469+
const auto opt_cbtx = GetTxPayload<CCbTx>(*cbTx);
474470

475471
if (!opt_cbtx.has_value()) {
476472
return std::nullopt;
477473
}
478474

479-
CCbTx& cbtx = opt_cbtx.value();
480-
475+
const CCbTx& cbtx = opt_cbtx.value();
481476
if (cbtx.nVersion < CCbTx::Version::CLSIG_AND_BALANCE) {
482477
return std::nullopt;
483478
}

src/evo/cbtx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ bool CheckCbTxBestChainlock(const CBlock& block, const CBlockIndex* pindexPrev,
100100
bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_handler, const CBlockIndex* pindexPrev,
101101
uint32_t& bestCLHeightDiff, CBLSSignature& bestCLSignature);
102102

103-
std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex);
104103
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex);
105104

106105
#endif // BITCOIN_EVO_CBTX_H

src/evo/creditpool.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
#ifndef BITCOIN_EVO_CREDITPOOL_H
66
#define BITCOIN_EVO_CREDITPOOL_H
77

8-
#include <coins.h>
9-
10-
#include <evo/assetlocktx.h>
11-
8+
#include <consensus/amount.h>
129
#include <saltedhasher.h>
1310
#include <serialize.h>
1411
#include <sync.h>
1512
#include <threadsafety.h>
1613
#include <unordered_lru_cache.h>
1714
#include <util/ranges_set.h>
1815

16+
#include <evo/assetlocktx.h>
17+
1918
#include <optional>
2019
#include <unordered_set>
2120

2221
class BlockManager;
22+
class CBlock;
2323
class CBlockIndex;
2424
class BlockValidationState;
2525
class CEvoDB;

src/evo/deterministicmns.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
class CBlock;
3030
class CBlockIndex;
3131
class CChainState;
32+
class CCoinsViewCache;
3233
class CConnman;
3334
class CEvoDB;
3435
class TxValidationState;

src/evo/dmnstate.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
#ifndef BITCOIN_EVO_DMNSTATE_H
66
#define BITCOIN_EVO_DMNSTATE_H
77

8-
#include <crypto/common.h>
98
#include <bls/bls.h>
10-
#include <pubkey.h>
9+
#include <crypto/sha256.h>
10+
#include <evo/providertx.h>
1111
#include <netaddress.h>
12+
#include <pubkey.h>
1213
#include <script/script.h>
13-
#include <evo/providertx.h>
1414

1515
#include <memory>
1616
#include <utility>

src/evo/mnauth.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@ class CBlockIndex;
1414
class CChain;
1515
class CConnman;
1616
class CDataStream;
17-
class CDeterministicMN;
1817
class CDeterministicMNList;
1918
class CDeterministicMNListDiff;
20-
class CDeterministicMNManager;
2119
class CMasternodeMetaMan;
2220
class CMasternodeSync;
2321
class CNode;
2422

25-
class UniValue;
26-
2723
enum ServiceFlags : uint64_t;
2824

2925
/**

src/evo/mnhftx.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@
77

88
#include <bls/bls.h>
99
#include <gsl/pointers.h>
10-
#include <primitives/transaction.h>
1110
#include <sync.h>
1211
#include <threadsafety.h>
1312
#include <univalue.h>
1413

1514
#include <optional>
1615
#include <saltedhasher.h>
17-
#include <unordered_map>
1816
#include <unordered_lru_cache.h>
1917
#include <versionbits.h>
2018

2119
class BlockValidationState;
2220
class CBlock;
2321
class CBlockIndex;
2422
class CEvoDB;
23+
class CTransaction;
2524
class ChainstateManager;
2625
class TxValidationState;
2726
namespace llmq {

src/evo/providertx.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#include <univalue.h>
1818
#include <util/underlying.h>
1919

20-
class CBlockIndex;
21-
class CCoinsViewCache;
2220
class TxValidationState;
2321

2422
class CProRegTx

src/evo/simplifiedmns.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@
66
#define BITCOIN_EVO_SIMPLIFIEDMNS_H
77

88
#include <bls/bls.h>
9-
#include <evo/deterministicmns.h>
109
#include <evo/dmn_types.h>
1110
#include <merkleblock.h>
1211
#include <netaddress.h>
1312
#include <pubkey.h>
13+
#include <sync.h>
14+
#include <threadsafety.h>
1415

1516
class UniValue;
1617
class CBlockIndex;
17-
class CDeterministicMNList;
1818
class CDeterministicMN;
19+
class CDeterministicMNList;
20+
class CDeterministicMNManager;
1921
class ChainstateManager;
2022

23+
extern RecursiveMutex cs_main;
24+
2125
namespace llmq {
2226
class CFinalCommitment;
2327
class CQuorumBlockProcessor;

0 commit comments

Comments
 (0)