Skip to content

Commit 23c2044

Browse files
committed
refactor: return argument should be the last
Changes applied to CheckSpecialTx/ProcessSpecialTx
1 parent e06f577 commit 23c2044

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/evo/specialtxman.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <primitives/block.h>
1818
#include <validation.h>
1919

20-
bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state, const CCoinsViewCache& view, bool check_sigs)
20+
bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, bool check_sigs, TxValidationState& state)
2121
{
2222
AssertLockHeld(cs_main);
2323

@@ -100,7 +100,7 @@ bool UndoSpecialTx(const CTransaction& tx, const CBlockIndex* pindex)
100100
}
101101

102102
bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CChainLocksHandler& chainlock_handler,
103-
BlockValidationState& state, const CCoinsViewCache& view, bool fJustCheck, bool fCheckCbTxMerleRoots)
103+
const CCoinsViewCache& view, bool fJustCheck, bool fCheckCbTxMerleRoots, BlockValidationState& state)
104104
{
105105
AssertLockHeld(cs_main);
106106

@@ -117,7 +117,7 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, ll
117117
TxValidationState tx_state;
118118
// At this moment CheckSpecialTx() and ProcessSpecialTx() may fail by 2 possible ways:
119119
// consensus failures and "TX_BAD_SPECIAL"
120-
if (!CheckSpecialTx(*ptr_tx, pindex->pprev, tx_state, view, fCheckCbTxMerleRoots)) {
120+
if (!CheckSpecialTx(*ptr_tx, pindex->pprev, view, fCheckCbTxMerleRoots, tx_state)) {
121121
assert(tx_state.GetResult() == TxValidationResult::TX_CONSENSUS || tx_state.GetResult() == TxValidationResult::TX_BAD_SPECIAL);
122122
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, tx_state.GetRejectReason(),
123123
strprintf("Special Transaction check failed (tx hash %s) %s", ptr_tx->GetHash().ToString(), tx_state.GetDebugMessage()));

src/evo/specialtxman.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class CChainLocksHandler;
2121

2222
extern RecursiveMutex cs_main;
2323

24-
bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state, const CCoinsViewCache& view, bool check_sigs) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
24+
bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, const CCoinsViewCache& view, bool check_sigs, TxValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
2525
bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CChainLocksHandler& chainlock_handler,
26-
BlockValidationState& state, const CCoinsViewCache& view, bool fJustCheck, bool fCheckCbTxMerleRoots) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
26+
const CCoinsViewCache& view, bool fJustCheck, bool fCheckCbTxMerleRoots, BlockValidationState& state) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
2727
bool UndoSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, llmq::CQuorumBlockProcessor& quorum_block_processor) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
2828

2929
#endif // BITCOIN_EVO_SPECIALTXMAN_H

src/rpc/evo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static std::string SignAndSendSpecialTx(const JSONRPCRequest& request, const CMu
329329
LOCK(cs_main);
330330

331331
TxValidationState state;
332-
if (!CheckSpecialTx(CTransaction(tx), ::ChainActive().Tip(), state, ::ChainstateActive().CoinsTip(), true)) {
332+
if (!CheckSpecialTx(CTransaction(tx), ::ChainActive().Tip(), ::ChainstateActive().CoinsTip(), true, state)) {
333333
throw std::runtime_error(state.ToString());
334334
}
335335
} // cs_main

src/validation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws)
823823
// DoS scoring a node for non-critical errors, e.g. duplicate keys because a TX is received that was already
824824
// mined
825825
// NOTE: we use UTXO here and do NOT allow mempool txes as masternode collaterals
826-
if (!CheckSpecialTx(tx, m_active_chainstate.m_chain.Tip(), state, m_active_chainstate.CoinsTip(), true))
826+
if (!CheckSpecialTx(tx, m_active_chainstate.m_chain.Tip(), m_active_chainstate.CoinsTip(), true, state))
827827
return false;
828828

829829
if (m_pool.existsProviderTxConflict(tx)) {
@@ -2253,7 +2253,7 @@ bool CChainState::ConnectBlock(const CBlock& block, BlockValidationState& state,
22532253
bool fDIP0001Active_context = pindex->nHeight >= Params().GetConsensus().DIP0001Height;
22542254

22552255
// MUST process special txes before updating UTXO to ensure consistency between mempool and block processing
2256-
if (!ProcessSpecialTxsInBlock(block, pindex, *m_llmq_ctx->quorum_block_processor, *m_llmq_ctx->clhandler, state, view, fJustCheck, fScriptChecks)) {
2256+
if (!ProcessSpecialTxsInBlock(block, pindex, *m_llmq_ctx->quorum_block_processor, *m_llmq_ctx->clhandler, view, fJustCheck, fScriptChecks, state)) {
22572257
return error("ConnectBlock(DASH): ProcessSpecialTxsInBlock for block %s failed with %s",
22582258
pindex->GetBlockHash().ToString(), state.ToString());
22592259
}
@@ -4902,7 +4902,7 @@ bool CChainState::RollforwardBlock(const CBlockIndex* pindex, CCoinsViewCache& i
49024902

49034903
// MUST process special txes before updating UTXO to ensure consistency between mempool and block processing
49044904
BlockValidationState state;
4905-
if (!ProcessSpecialTxsInBlock(block, pindex, *m_llmq_ctx->quorum_block_processor, *m_llmq_ctx->clhandler, state, inputs, false /*fJustCheck*/, false /*fScriptChecks*/)) {
4905+
if (!ProcessSpecialTxsInBlock(block, pindex, *m_llmq_ctx->quorum_block_processor, *m_llmq_ctx->clhandler, inputs, false /*fJustCheck*/, false /*fScriptChecks*/, state)) {
49064906
return error("RollforwardBlock(DASH): ProcessSpecialTxsInBlock for block %s failed with %s",
49074907
pindex->GetBlockHash().ToString(), state.ToString());
49084908
}

0 commit comments

Comments
 (0)