Skip to content

Commit

Permalink
There can be no two votes which differ by the outcome only (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
UdjinM6 committed Apr 1, 2019
1 parent a87909e commit 377dd3b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/governance-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ bool CGovernanceObject::ProcessVote(CNode* pfrom,
LogPrint("gobject", "%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_NONE);
return false;
} else if (vote.GetTimestamp() == voteInstanceRef.nCreationTime) {
// Someone is doing smth fishy, there can be no two votes from the same masternode
// with the same timestamp for the same object and signal and yet different hash/outcome.
std::ostringstream ostr;
ostr << "CGovernanceObject::ProcessVote -- Invalid vote, same timestamp for the different outcome";
if (vote.GetOutcome() < voteInstanceRef.eOutcome) {
// This is an arbitrary comparison, we have to agree on some way
// to pick the "winning" vote.
ostr << ", rejected";
LogPrint("gobject", "%s\n", ostr.str());
exception = CGovernanceException(ostr.str(), GOVERNANCE_EXCEPTION_NONE);
return false;
}
ostr << ", accepted";
LogPrint("gobject", "%s\n", ostr.str());
}

int64_t nNow = GetAdjustedTime();
Expand Down

0 comments on commit 377dd3b

Please sign in to comment.