|
5 | 5 | #include <evo/specialtxman.h> |
6 | 6 |
|
7 | 7 | #include <chainparams.h> |
| 8 | +#include <consensus/amount.h> |
8 | 9 | #include <consensus/validation.h> |
9 | 10 | #include <deploymentstatus.h> |
10 | 11 | #include <evo/assetlocktx.h> |
@@ -150,8 +151,7 @@ bool CSpecialTxProcessor::ProcessSpecialTxsInBlock(const CBlock& block, const CB |
150 | 151 | LogPrint(BCLog::BENCHMARK, " - Loop: %.2fms [%.2fs]\n", 0.001 * (nTime3 - nTime2), nTimeLoop * 0.000001); |
151 | 152 |
|
152 | 153 | if (fCheckCbTxMerkleRoots && block.vtx[0]->nType == TRANSACTION_COINBASE) { |
153 | | - CAmount blockSubsidy = GetBlockSubsidy(pindex, m_consensus_params); |
154 | | - if (!CheckCreditPoolDiffForBlock(block, pindex, *opt_cbTx, blockSubsidy, state)) { |
| 154 | + if (!CheckCreditPoolDiffForBlock(block, pindex, *opt_cbTx, state)) { |
155 | 155 | return error("CSpecialTxProcessor: CheckCreditPoolDiffForBlock for block %s failed with %s", |
156 | 156 | pindex->GetBlockHash().ToString(), state.ToString()); |
157 | 157 | } |
@@ -275,21 +275,22 @@ bool CSpecialTxProcessor::UndoSpecialTxsInBlock(const CBlock& block, const CBloc |
275 | 275 | } |
276 | 276 |
|
277 | 277 | bool CSpecialTxProcessor::CheckCreditPoolDiffForBlock(const CBlock& block, const CBlockIndex* pindex, const CCbTx& cbTx, |
278 | | - const CAmount blockSubsidy, BlockValidationState& state) |
| 278 | + BlockValidationState& state) |
279 | 279 | { |
280 | 280 | AssertLockHeld(cs_main); |
281 | 281 |
|
282 | | - try { |
283 | | - if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_DIP0003)) return true; |
284 | | - if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_DIP0008)) return true; |
285 | | - if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_V20)) return true; |
| 282 | + if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_DIP0008)) return true; |
| 283 | + if (!DeploymentActiveAt(*pindex, m_consensus_params, Consensus::DEPLOYMENT_V20)) return true; |
286 | 284 |
|
287 | | - auto creditPoolDiff = GetCreditPoolDiffForBlock(m_cpoolman, m_chainman.m_blockman, m_qman, block, pindex->pprev, m_consensus_params, blockSubsidy, state); |
| 285 | + try { |
| 286 | + const CAmount blockSubsidy = GetBlockSubsidy(pindex, m_consensus_params); |
| 287 | + const auto creditPoolDiff = GetCreditPoolDiffForBlock(m_cpoolman, m_chainman.m_blockman, m_qman, block, |
| 288 | + pindex->pprev, m_consensus_params, blockSubsidy, state); |
288 | 289 | if (!creditPoolDiff.has_value()) return false; |
289 | 290 |
|
290 | | - CAmount target_balance{cbTx.creditPoolBalance}; |
| 291 | + const CAmount target_balance{cbTx.creditPoolBalance}; |
291 | 292 | // But it maybe not included yet in previous block yet; in this case value must be 0 |
292 | | - CAmount locked_calculated{creditPoolDiff->GetTotalLocked()}; |
| 293 | + const CAmount locked_calculated{creditPoolDiff->GetTotalLocked()}; |
293 | 294 | if (target_balance != locked_calculated) { |
294 | 295 | LogPrintf("CSpecialTxProcessor::%s -- mismatched locked amount in CbTx: %lld against re-calculated: %lld\n", __func__, target_balance, locked_calculated); |
295 | 296 | return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cbtx-assetlocked-amount"); |
|
0 commit comments