From 0772f201c7c10e274fffcae11ec26577c36054a2 Mon Sep 17 00:00:00 2001 From: alex v Date: Tue, 13 Apr 2021 10:41:59 +0200 Subject: [PATCH] Prevent excessive remove votes (#827) * prevent excessive remove votes * remove log --- src/miner.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 6a6f3b38f..53e55553f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1166,6 +1166,8 @@ bool SignBlock(CBlock *pblock, CWallet& wallet, int64_t nFees, std::string sLog) std::map mapCountAnswers; std::map mapCacheMaxAnswers; + CProposal proposal; + CPaymentRequest prequest; CConsultation consultation; CConsultationAnswer answer; @@ -1330,8 +1332,8 @@ bool SignBlock(CBlock *pblock, CWallet& wallet, int64_t nFees, std::string sLog) uint256 hash = it.first; int64_t val = it.second; - bool fProposal = view.HaveProposal(hash); - bool fPaymentRequest = view.HavePaymentRequest(hash); + bool fProposal = view.HaveProposal(hash) && view.GetProposal(hash, proposal) && proposal.CanVote(view); + bool fPaymentRequest = view.HavePaymentRequest(hash) && view.GetPaymentRequest(hash, prequest) && prequest.CanVote(view); if (val != VoteFlags::VOTE_REMOVE && mapAddedVotes.count(hash) == 0 && votes.count(hash) == 0 && (fProposal || fPaymentRequest) && !(pblock->nNonce & 1)) { @@ -1347,8 +1349,8 @@ bool SignBlock(CBlock *pblock, CWallet& wallet, int64_t nFees, std::string sLog) votes[hash] = true; } - bool fConsultation = view.HaveConsultation(hash) && view.GetConsultation(hash, consultation); - bool fAnswer = view.HaveConsultationAnswer(hash) && view.GetConsultationAnswer(hash, answer); + bool fConsultation = view.HaveConsultation(hash) && view.GetConsultation(hash, consultation) && consultation.CanBeVoted(val); + bool fAnswer = view.HaveConsultationAnswer(hash) && view.GetConsultationAnswer(hash, answer) && answer.CanBeVoted(view); if ((fConsultation || fAnswer) && !(pblock->nNonce & 1)) {