Skip to content

Commit

Permalink
Allow skipping of MN payments with zero duffs (#2534)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
codablock authored Dec 6, 2018
1 parent d94092b commit 225c213
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 225c213

Please sign in to comment.