From 10fdfb030126985e534468b00f24e9232e22f521 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 29 Sep 2023 21:10:15 +0300 Subject: [PATCH] fix: blockReward should be provided for cbtx-es only, assert that in ProcessTransaction --- src/evo/creditpool.cpp | 13 ++++++++----- src/evo/creditpool.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/evo/creditpool.cpp b/src/evo/creditpool.cpp index 89b3df34e411e9..26122609c6b2ef 100644 --- a/src/evo/creditpool.cpp +++ b/src/evo/creditpool.cpp @@ -228,7 +228,7 @@ void CCreditPoolDiff::AddRewardRealloced(const CAmount reward) { platformReward += reward; } -bool CCreditPoolDiff::SetTarget(const CTransaction& tx, const std::optional blockReward, TxValidationState& state) +bool CCreditPoolDiff::SetTarget(const CTransaction& tx, const CAmount blockReward, TxValidationState& state) { CCbTx cbTx; if (!GetTxPayload(tx, cbTx)) { @@ -241,9 +241,7 @@ bool CCreditPoolDiff::SetTarget(const CTransaction& tx, const std::optional blockReward, TxValidationState& state) { if (tx.nVersion != 3) return true; - if (tx.nType == TRANSACTION_COINBASE) return SetTarget(tx, blockReward, state); + + assert(blockReward.has_value() == (tx.nType == TRANSACTION_COINBASE)); + + if (tx.nType == TRANSACTION_COINBASE) { + return SetTarget(tx, blockReward.value(), state); + } if (tx.nType != TRANSACTION_ASSET_LOCK && tx.nType != TRANSACTION_ASSET_UNLOCK) return true; diff --git a/src/evo/creditpool.h b/src/evo/creditpool.h index 4a0d255485207b..206bc21a9e545a 100644 --- a/src/evo/creditpool.h +++ b/src/evo/creditpool.h @@ -102,7 +102,7 @@ class CCreditPoolDiff { } private: - bool SetTarget(const CTransaction& tx, const std::optional blockReward, TxValidationState& state); + bool SetTarget(const CTransaction& tx, const CAmount blockReward, TxValidationState& state); bool Lock(const CTransaction& tx, TxValidationState& state); bool Unlock(const CTransaction& tx, TxValidationState& state); };