44
55#include < consensus/validation.h>
66#include < evo/cbtx.h>
7- #include < evo/deterministicmns.h>
87#include < evo/simplifiedmns.h>
98#include < evo/specialtx.h>
109#include < llmq/blockprocessor.h>
@@ -61,9 +60,9 @@ bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidati
6160}
6261
6362// This can only be done after the block has been fully processed, as otherwise we won't have the finished MN list
64- bool CheckCbTxMerkleRoots (const CBlock& block, const CBlockIndex* pindex, CDeterministicMNManager& dmnman,
65- llmq::CQuorumSnapshotManager& qsnapman, const llmq::CQuorumBlockProcessor& quorum_block_processor,
66- BlockValidationState& state, const CCoinsViewCache& view )
63+ bool CheckCbTxMerkleRoots (const CBlock& block, const CBlockIndex* pindex,
64+ const llmq::CQuorumBlockProcessor& quorum_block_processor, CSimplifiedMNList&& sml ,
65+ BlockValidationState& state)
6766{
6867 if (block.vtx [0 ]->nType != TRANSACTION_COINBASE) {
6968 return true ;
@@ -87,7 +86,7 @@ bool CheckCbTxMerkleRoots(const CBlock& block, const CBlockIndex* pindex, CDeter
8786 static int64_t nTimeMerkleQuorum = 0 ;
8887
8988 uint256 calculatedMerkleRoot;
90- if (!CalcCbTxMerkleRootMNList (block, pindex-> pprev , calculatedMerkleRoot, state, dmnman, qsnapman, view )) {
89+ if (!CalcCbTxMerkleRootMNList (calculatedMerkleRoot, std::move (sml), state )) {
9190 // pass the state returned by the function above
9291 return false ;
9392 }
@@ -116,31 +115,13 @@ bool CheckCbTxMerkleRoots(const CBlock& block, const CBlockIndex* pindex, CDeter
116115 return true ;
117116}
118117
119- bool CalcCbTxMerkleRootMNList (const CBlock& block, const CBlockIndex* pindexPrev, uint256& merkleRootRet,
120- BlockValidationState& state, CDeterministicMNManager& dmnman,
121- llmq::CQuorumSnapshotManager& qsnapman, const CCoinsViewCache& view)
118+ bool CalcCbTxMerkleRootMNList (uint256& merkleRootRet, CSimplifiedMNList&& sml, BlockValidationState& state)
122119{
123120 try {
124- static std::atomic<int64_t > nTimeDMN = 0 ;
125- static std::atomic<int64_t > nTimeSMNL = 0 ;
126121 static std::atomic<int64_t > nTimeMerkle = 0 ;
127122
128123 int64_t nTime1 = GetTimeMicros ();
129124
130- CDeterministicMNList tmpMNList;
131- if (!dmnman.BuildNewListFromBlock (block, pindexPrev, state, view, tmpMNList, qsnapman, false )) {
132- // pass the state returned by the function above
133- return false ;
134- }
135-
136- int64_t nTime2 = GetTimeMicros (); nTimeDMN += nTime2 - nTime1;
137- LogPrint (BCLog::BENCHMARK, " - BuildNewListFromBlock: %.2fms [%.2fs]\n " , 0.001 * (nTime2 - nTime1), nTimeDMN * 0.000001 );
138-
139- CSimplifiedMNList sml (tmpMNList);
140-
141- int64_t nTime3 = GetTimeMicros (); nTimeSMNL += nTime3 - nTime2;
142- LogPrint (BCLog::BENCHMARK, " - CSimplifiedMNList: %.2fms [%.2fs]\n " , 0.001 * (nTime3 - nTime2), nTimeSMNL * 0.000001 );
143-
144125 static Mutex cached_mutex;
145126 static CSimplifiedMNList smlCached GUARDED_BY (cached_mutex);
146127 static uint256 merkleRootCached GUARDED_BY (cached_mutex);
@@ -158,8 +139,10 @@ bool CalcCbTxMerkleRootMNList(const CBlock& block, const CBlockIndex* pindexPrev
158139 bool mutated = false ;
159140 merkleRootRet = sml.CalcMerkleRoot (&mutated);
160141
161- int64_t nTime4 = GetTimeMicros (); nTimeMerkle += nTime4 - nTime3;
162- LogPrint (BCLog::BENCHMARK, " - CalcMerkleRoot: %.2fms [%.2fs]\n " , 0.001 * (nTime4 - nTime3), nTimeMerkle * 0.000001 );
142+ int64_t nTime2 = GetTimeMicros ();
143+ nTimeMerkle += nTime2 - nTime1;
144+ LogPrint (BCLog::BENCHMARK, " - CalcMerkleRoot: %.2fms [%.2fs]\n " , 0.001 * (nTime2 - nTime1),
145+ nTimeMerkle * 0.000001 );
163146
164147 smlCached = std::move (sml);
165148 merkleRootCached = merkleRootRet;
0 commit comments