From 225c2135e211d83ff2ff41dc25117004834da5d1 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Thu, 6 Dec 2018 14:43:54 +0100 Subject: [PATCH] Allow skipping of MN payments with zero duffs (#2534) * Allow skipping of MN payments with zero duffs In case a MNO uses an operator reward of 100%, the normal reward will be 0 duffs. It doesn't make sense to enforce these payments. This will cause a fork when miners start to mine with the new version, but only for nodes that didn't upgrade. * Apply suggestions from code review Co-Authored-By: codablock --- src/masternode-payments.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 2c14bc1eb..61da6eaeb 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -610,14 +610,21 @@ bool CMasternodePayments::GetBlockTxOuts(int nBlockHeight, CAmount blockReward, return false; } - if (dmnPayee->nOperatorReward == 0 || dmnPayee->pdmnState->scriptOperatorPayout == CScript()) { - voutMasternodePaymentsRet.emplace_back(masternodeReward, dmnPayee->pdmnState->scriptPayout); - } else { - CAmount operatorReward = (masternodeReward * dmnPayee->nOperatorReward) / 10000; + CAmount operatorReward = 0; + if (dmnPayee->nOperatorReward != 0 && dmnPayee->pdmnState->scriptOperatorPayout != CScript()) { + // This calculation might eventually turn out to result in 0 even if an operator reward percentage is given. + // This will however only happen in a few years when the block rewards drops very low. + operatorReward = (masternodeReward * dmnPayee->nOperatorReward) / 10000; masternodeReward -= operatorReward; + } + + if (masternodeReward > 0) { voutMasternodePaymentsRet.emplace_back(masternodeReward, dmnPayee->pdmnState->scriptPayout); + } + if (operatorReward > 0) { voutMasternodePaymentsRet.emplace_back(operatorReward, dmnPayee->pdmnState->scriptOperatorPayout); } + return true; } else { LOCK(cs_mapMasternodeBlocks);