Skip to content

Commit

Permalink
fix: correct conditions for YES voting
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Aug 12, 2024
1 parent 4255a43 commit bfb6fce
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/governance/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,13 +736,16 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGover
assert(!votedFundingYesTriggerHash.has_value());
// Vote YES-FUNDING for the trigger we like, unless we already did
const uint256 gov_sb_hash = trigger_opt.value().GetHash();
bool voted_already{false};
if (vote_rec_t voteRecord; trigger_opt.value().GetCurrentMNVotes(mn_activeman.GetOutPoint(), voteRecord)) {
const auto& strFunc = __func__;
// Let's see if there is a VOTE_SIGNAL_FUNDING vote from us already
ranges::any_of(voteRecord.mapInstances, [&](const auto& voteInstancePair) {
if (voteInstancePair.first == VOTE_SIGNAL_FUNDING) {
if (voteInstancePair.second.eOutcome == VOTE_OUTCOME_YES) {
votedFundingYesTriggerHash = gov_sb_hash;
}
voted_already = true;
LogPrint(BCLog::GOBJECT, /* Continued */
"CGovernanceManager::%s "
"Not voting YES-FUNDING for trigger:%s, we voted %s for it already\n",
Expand All @@ -752,14 +755,19 @@ void CGovernanceManager::VoteGovernanceTriggers(const std::optional<const CGover
}
return false;
});
} else if (VoteFundingTrigger(gov_sb_hash, VOTE_OUTCOME_YES, connman, peerman, mn_activeman)) {
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Voting YES-FUNDING for new trigger:%s success\n", __func__,
gov_sb_hash.ToString());
votedFundingYesTriggerHash = gov_sb_hash;
} else {
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Voting YES-FUNDING for new trigger:%s failed\n", __func__, gov_sb_hash.ToString());
// this should never happen, bail out
return;
}
if (!voted_already) {
// No previous VOTE_SIGNAL_FUNDING was found, vote now
if (VoteFundingTrigger(gov_sb_hash, VOTE_OUTCOME_YES, connman, peerman, mn_activeman)) {
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Voting YES-FUNDING for new trigger:%s success\n",
__func__, gov_sb_hash.ToString());
votedFundingYesTriggerHash = gov_sb_hash;
} else {
LogPrint(BCLog::GOBJECT, "CGovernanceManager::%s Voting YES-FUNDING for new trigger:%s failed\n",
__func__, gov_sb_hash.ToString());
// this should never happen, bail out
return;
}
}
}

Expand Down

0 comments on commit bfb6fce

Please sign in to comment.