|
7 | 7 | #include <evo/assetlocktx.h> |
8 | 8 | #include <evo/cbtx.h> |
9 | 9 |
|
10 | | -#include <llmq/utils.h> |
11 | | - |
12 | 10 | #include <chain.h> |
| 11 | +#include <llmq/utils.h> |
13 | 12 | #include <logging.h> |
| 13 | +#include <spork.h> |
14 | 14 | #include <util/validation.h> |
15 | 15 | #include <validation.h> |
16 | 16 |
|
@@ -251,16 +251,31 @@ CCreditPoolDiff::CCreditPoolDiff(CCreditPool starter, const CBlockIndex *pindex, |
251 | 251 | assert(pindex); |
252 | 252 | } |
253 | 253 |
|
| 254 | +void CCreditPoolDiff::addRewardRealloced(const CAmount reward) { |
| 255 | + masternodeReward += reward; |
| 256 | +} |
| 257 | + |
254 | 258 | bool CCreditPoolDiff::setTarget(const CTransaction& tx, TxValidationState& state) |
255 | 259 | { |
256 | 260 | CCbTx cbTx; |
257 | 261 | if (!GetTxPayload(tx, cbTx)) { |
258 | 262 | return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-cbtx-payload"); |
259 | 263 | } |
260 | 264 |
|
261 | | - if (cbTx.nVersion == 3) { |
262 | | - targetLocked = cbTx.assetLockedAmount; |
| 265 | + if (cbTx.nVersion != 3) return true; |
| 266 | + |
| 267 | + targetLocked = cbTx.assetLockedAmount; |
| 268 | + |
| 269 | + |
| 270 | + if (isIgnoringMNRewardReallocation(*sporkManager)) return true; |
| 271 | + |
| 272 | + CAmount blockReward = 0; |
| 273 | + for (const CTxOut& txout : tx.vout) { |
| 274 | + blockReward += txout.nValue; |
263 | 275 | } |
| 276 | + masternodeReward = GetMasternodePayment(cbTx.nHeight, blockReward, Params().GetConsensus().BRRHeight); |
| 277 | + LogPrintf("CreditPool: set target to %lld with MN reward %lld\n", *targetLocked, masternodeReward); |
| 278 | + |
264 | 279 | return true; |
265 | 280 | } |
266 | 281 |
|
@@ -333,3 +348,11 @@ bool CCreditPoolDiff::processTransaction(const CTransaction& tx, TxValidationSta |
333 | 348 | return state.Invalid(TxValidationResult::TX_CONSENSUS, "failed-procassetlocksinblock"); |
334 | 349 | } |
335 | 350 | } |
| 351 | + |
| 352 | +bool isIgnoringMNRewardReallocation(const CSporkManager& spork_manager) { |
| 353 | + if (Params().NetworkIDString() != CBaseChainParams::REGTEST) return false; |
| 354 | + |
| 355 | + bool ret = spork_manager.IsSporkActive(SPORK_24_IGNORE_MN_REWARD_REALLOCED); |
| 356 | + LogPrintf("%s: spork IGNORE_MN_REWARD_REALLOCED value: %d\n", __func__, ret); |
| 357 | + return ret; |
| 358 | +} |
0 commit comments