You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As per the contract GeneralElections.sol, if a candidate receives more than half of the total votes, they are the sole winner. If no candidate receives more than half of the total votes, all candidates with the highest number of votes are considered winners.
The problem is in the latter part. Currently, the application logs all the winners of an election but only stores the first winner in the _winnerDetails array. This means that if there are multiple winners, only the first one is considered by the application and is declared as the winner.
Problem:
This could lead to incorrect results in elections where there are multiple winners. For example, in a tied election where there are two or more winners, only the first winner is stored and considered by the application.
Steps to Reproduce:
Conduct an election where there are multiple winners.
Observe the winner after the election. The candidate who has higher ranked id will be shown as winner, but in actual, both should be declared as winners.
Expected Result:
All winners should be stored in the _winnerDetails array and considered by the application.
Actual Result:
Only the first winner is stored in the _winnerDetails array and considered by the application.
Proposed Solution:
Modify the code to store all winners in the _winnerDetails array and show them as winners
The text was updated successfully, but these errors were encountered:
Description:
As per the contract
GeneralElections.sol
, if a candidate receives more than half of the total votes, they are the sole winner. If no candidate receives more than half of the total votes, all candidates with the highest number of votes are considered winners.The problem is in the latter part. Currently, the application logs all the winners of an election but only stores the first winner in the
_winnerDetails
array. This means that if there are multiple winners, only the first one is considered by the application and is declared as the winner.Problem:
This could lead to incorrect results in elections where there are multiple winners. For example, in a tied election where there are two or more winners, only the first winner is stored and considered by the application.
Steps to Reproduce:
Expected Result:
All winners should be stored in the
_winnerDetails
array and considered by the application.Actual Result:
Only the first winner is stored in the
_winnerDetails
array and considered by the application.Proposed Solution:
Modify the code to store all winners in the
_winnerDetails
array and show them as winnersThe text was updated successfully, but these errors were encountered: