1313#include < hash.h>
1414#include < llmq/blockprocessor.h>
1515#include < llmq/commitment.h>
16+ #include < llmq/context.h>
1617#include < llmq/utils.h>
1718#include < primitives/block.h>
1819#include < validation.h>
1920
20- bool CheckSpecialTx (const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, bool check_sigs, TxValidationState& state)
21+ namespace llmq {
22+ class CChainLocksHandler ;
23+ } // namespace llmq
24+
25+ bool CheckSpecialTx (const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, LLMQContext& llmq_ctx, bool check_sigs, TxValidationState& state)
2126{
2227 AssertLockHeld (cs_main);
2328
@@ -43,7 +48,7 @@ bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const
4348 case TRANSACTION_QUORUM_COMMITMENT:
4449 return llmq::CheckLLMQCommitment (tx, pindexPrev, state);
4550 case TRANSACTION_MNHF_SIGNAL:
46- return pindexPrev->nHeight + 1 >= Params ().GetConsensus ().DIP0024Height && CheckMNHFTx (tx, pindexPrev, state);
51+ return pindexPrev->nHeight + 1 >= Params ().GetConsensus ().DIP0024Height && CheckMNHFTx (tx, pindexPrev, *llmq_ctx. qman , state);
4752 }
4853 } catch (const std::exception& e) {
4954 LogPrintf (" %s -- failed: %s\n " , __func__, e.what ());
@@ -99,10 +104,12 @@ bool UndoSpecialTx(const CTransaction& tx, const CBlockIndex* pindex)
99104 return false ;
100105}
101106
102- bool ProcessSpecialTxsInBlock (const CBlock& block, const CBlockIndex* pindex, llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CChainLocksHandler& chainlock_handler ,
103- const CCoinsViewCache& view , bool fJustCheck , bool fCheckCbTxMerleRoots , BlockValidationState& state)
107+ bool ProcessSpecialTxsInBlock (const CBlock& block, const CBlockIndex* pindex, const CCoinsViewCache& view ,
108+ LLMQContext& llmq_ctx , bool fJustCheck , bool fCheckCbTxMerleRoots , BlockValidationState& state)
104109{
105110 AssertLockHeld (cs_main);
111+ llmq::CQuorumBlockProcessor& quorum_block_processor = *llmq_ctx.quorum_block_processor ;
112+ const llmq::CChainLocksHandler& chainlock_handler = *llmq_ctx.clhandler ;
106113
107114 try {
108115 static int64_t nTimeLoop = 0 ;
@@ -117,7 +124,7 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, ll
117124 TxValidationState tx_state;
118125 // At this moment CheckSpecialTx() and ProcessSpecialTx() may fail by 2 possible ways:
119126 // consensus failures and "TX_BAD_SPECIAL"
120- if (!CheckSpecialTx (*ptr_tx, pindex->pprev , view, fCheckCbTxMerleRoots , tx_state)) {
127+ if (!CheckSpecialTx (*ptr_tx, pindex->pprev , view, llmq_ctx, fCheckCbTxMerleRoots , tx_state)) {
121128 assert (tx_state.GetResult () == TxValidationResult::TX_CONSENSUS || tx_state.GetResult () == TxValidationResult::TX_BAD_SPECIAL);
122129 return state.Invalid (BlockValidationResult::BLOCK_CONSENSUS, tx_state.GetRejectReason (),
123130 strprintf (" Special Transaction check failed (tx hash %s) %s" , ptr_tx->GetHash ().ToString (), tx_state.GetDebugMessage ()));
@@ -133,7 +140,7 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, ll
133140 nTimeLoop += nTime2 - nTime1;
134141 LogPrint (BCLog::BENCHMARK, " - Loop: %.2fms [%.2fs]\n " , 0.001 * (nTime2 - nTime1), nTimeLoop * 0.000001 );
135142
136- if (!quorum_block_processor.ProcessBlock (block, pindex, state , fJustCheck , fCheckCbTxMerleRoots )) {
143+ if (!quorum_block_processor.ProcessBlock (block, pindex, *llmq_ctx. qman , fJustCheck , fCheckCbTxMerleRoots , state )) {
137144 // pass the state returned by the function above
138145 return false ;
139146 }
@@ -183,10 +190,10 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, ll
183190 return true ;
184191}
185192
186- bool UndoSpecialTxsInBlock (const CBlock& block, const CBlockIndex* pindex, llmq::CQuorumBlockProcessor& quorum_block_processor )
193+ bool UndoSpecialTxsInBlock (const CBlock& block, const CBlockIndex* pindex, LLMQContext& llmq_ctx )
187194{
188195 AssertLockHeld (cs_main);
189-
196+ llmq::CQuorumBlockProcessor& quorum_block_processor = *llmq_ctx. quorum_block_processor ;
190197 auto bls_legacy_scheme = bls::bls_legacy_scheme.load ();
191198
192199 try {
@@ -208,7 +215,7 @@ bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, llmq:
208215 return false ;
209216 }
210217
211- if (!quorum_block_processor.UndoBlock (block, pindex)) {
218+ if (!quorum_block_processor.UndoBlock (block, pindex, *llmq_ctx. qman )) {
212219 return false ;
213220 }
214221 } catch (const std::exception& e) {
0 commit comments