Skip to content

Commit

Permalink
Revert "Remove CalcMissingRewardTempFix"
Browse files Browse the repository at this point in the history
This reverts commit db227f7.
  • Loading branch information
Bushstar committed Mar 3, 2023
1 parent db227f7 commit 4c15585
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/masternodes/masternodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,3 +1325,24 @@ CAmount CCustomCSView::GetFeeBurnPctFromAttributes() const {
return attributes->GetValue(feeBurnPctKey, Params().GetConsensus().props.feeBurnPct);
}

void CalcMissingRewardTempFix(CCustomCSView &mnview, const uint32_t targetHeight, const CWallet &wallet) {
mnview.ForEachMasternode([&](const uint256 &id, const CMasternode &node) {
if (node.rewardAddressType) {
const CScript rewardAddress = GetScriptForDestination(node.rewardAddressType == PKHashType ?
CTxDestination(PKHash(node.rewardAddress)) :
CTxDestination(WitnessV0KeyHash(node.rewardAddress)));
if (IsMineCached(wallet, rewardAddress) == ISMINE_SPENDABLE) {
mnview.CalculateOwnerRewards(rewardAddress, targetHeight);
}
}

const CScript rewardAddress = GetScriptForDestination(node.ownerType == PKHashType ?
CTxDestination(PKHash(node.ownerAuthAddress)) :
CTxDestination(WitnessV0KeyHash(node.ownerAuthAddress)));
if (IsMineCached(wallet, rewardAddress) == ISMINE_SPENDABLE) {
mnview.CalculateOwnerRewards(rewardAddress, targetHeight);
}

return true;
});
}
4 changes: 4 additions & 0 deletions src/masternodes/masternodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ CAmount GetTokenCreationFee(int height);
CAmount GetMnCollateralAmount(int height);
CAmount GetProposalCreationFee(int height, const CCustomCSView &view, const CCreateProposalMessage &msg);

// Update owner rewards for MNs missing call to CalculateOwnerRewards after voter fee distributions.
// Missing call fixed in: https://github.com/DeFiCh/ain/pull/1766
void CalcMissingRewardTempFix(CCustomCSView &mnview, const uint32_t targetHeight, const CWallet &wallet);

enum class UpdateMasternodeType : uint8_t {
None = 0x00,
OwnerAddress = 0x01,
Expand Down

0 comments on commit 4c15585

Please sign in to comment.