Skip to content

Commit

Permalink
Revert "Revert "Add undo in ReversGeneralCoinbaseTx() (#1641)""
Browse files Browse the repository at this point in the history
This reverts commit 152eda8.
  • Loading branch information
Jouzo committed Jan 30, 2023
1 parent 152eda8 commit cbbeb30
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2223,23 +2223,34 @@ void ReverseGeneralCoinbaseTx(CCustomCSView & mnview, int height, const Consensu

// Remove Loan and Options balances from Unallocated
if ((height < Params().GetConsensus().FortCanningHeight && kv.first == CommunityAccountType::Loan) ||
kv.first == CommunityAccountType::Options)
(height < consensus.GrandCentralHeight && kv.first == CommunityAccountType::Options))
{
mnview.SubCommunityBalance(CommunityAccountType::Unallocated, subsidy);
}
else
{
if (height >= consensus.GrandCentralHeight && kv.first == CommunityAccountType::CommunityDevFunds)
if (height >= consensus.GrandCentralHeight)
{
CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::GovernanceEnabled};
const auto attributes = mnview.GetAttributes();
assert(attributes);

auto attributes = mnview.GetAttributes();
if (!attributes) {
return;
}
if (!attributes->GetValue(enabledKey, false))
{
mnview.SubBalance(consensus.foundationShareScript, {DCT_ID{0}, subsidy});
if (kv.first == CommunityAccountType::CommunityDevFunds) {
CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::GovernanceEnabled};

if (!attributes->GetValue(enabledKey, false))
{
mnview.SubBalance(consensus.foundationShareScript, {DCT_ID{0}, subsidy});

continue;
}
} else if (kv.first == CommunityAccountType::Unallocated || kv.first == CommunityAccountType::Options) {
CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::EmissionUnusedFund};

if (attributes->GetValue(enabledKey, false)) {
mnview.SubBalance(consensus.unusedEmission, {DCT_ID{0}, subsidy});
} else {
mnview.SubCommunityBalance(CommunityAccountType::Unallocated, subsidy);
}

continue;
}
Expand Down

0 comments on commit cbbeb30

Please sign in to comment.