Skip to content

Commit

Permalink
Merge bitcoin#2645: [Tiertwo] Clean inactive MNs from the fin count.
Browse files Browse the repository at this point in the history
8d7fc85 tiertwo: clean inactive MNs from the fin count. (furszy)

Pull request description:

  same as it's done on the proposals side.

ACKs for top commit:
  random-zebra:
    utACK 8d7fc85
  Fuzzbawls:
    utACK 8d7fc85

Tree-SHA512: d31baabf3183192bbcf9fb5f1d5de5c3dd797493ca118178835fd5d355a3616de630e4f8c13802dcea416b920f56cefb3a25147c656c4b28501e6cb9a3838b9f
  • Loading branch information
random-zebra committed Nov 25, 2021
2 parents b5b7431 + 8d7fc85 commit 9c67b0a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/budget/finalizedbudget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,17 @@ bool CFinalizedBudget::UpdateValid(int nCurrentHeight)
return true;
}

int CFinalizedBudget::GetVoteCount() const
{
int ret = 0;
for (const auto& it : mapVotes) {
if (it.second.IsValid()) {
ret++;
}
}
return ret;
}

std::vector<uint256> CFinalizedBudget::GetVotesHashes() const
{
std::vector<uint256> vRet;
Expand Down
2 changes: 1 addition & 1 deletion src/budget/finalizedbudget.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class CFinalizedBudget
int GetBlockStart() const { return nBlockStart; }
int GetBlockEnd() const { return nBlockStart + (int)(vecBudgetPayments.size() - 1); }
const uint256& GetFeeTXHash() const { return nFeeTXHash; }
int GetVoteCount() const { return (int)mapVotes.size(); }
int GetVoteCount() const;
std::vector<uint256> GetVotesHashes() const;
bool IsPaidAlready(const uint256& nProposalHash, const uint256& nBlockHash, int nBlockHeight) const;
TrxValidationStatus IsTransactionValid(const CTransaction& txNew, const uint256& nBlockHash, int nBlockHeight) const;
Expand Down
2 changes: 2 additions & 0 deletions test/functional/tiertwo_governance_sync_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ def run_test(self):
self.stake(15, [self.remoteTwo]) # create blocks to remove staled votes
time.sleep(2) # wait a little bit
self.check_vote_existence(firstProposal.name, self.mnOneCollateral.hash, "YES", False)
self.check_budget_finalization_sync(2, "OK") # budget finalization vote removal
self.log.info("MN1 vote expired after collateral spend, all good")

self.log.info("expiring DMN1..")
Expand All @@ -369,6 +370,7 @@ def run_test(self):
self.stake(15, [self.remoteTwo]) # create blocks to remove staled votes
time.sleep(2) # wait a little bit
self.check_vote_existence(firstProposal.name, self.proRegTx1, "YES", False)
self.check_budget_finalization_sync(1, "OK") # budget finalization vote removal
self.log.info("DMN vote expired after collateral spend, all good")

# Check that the budget is removed 200 blocks after the last payment
Expand Down

0 comments on commit 9c67b0a

Please sign in to comment.