Skip to content

Commit

Permalink
fix: Add exception handling code to HeightVoteSet for votes with null…
Browse files Browse the repository at this point in the history
… power
  • Loading branch information
s2quake committed Oct 22, 2024
1 parent 4113b97 commit 61ffe8c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Libplanet.Net/Consensus/HeightVoteSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,12 @@ public void AddVote(Vote vote)
vote);
}

if (vote.ValidatorPower is { } power &&
_validatorSet.GetValidator(validatorKey).Power != power)
if (vote.ValidatorPower is not { } power)
{
const string msg = "ValidatorPower of the vote cannot be null";
throw new InvalidVoteException(msg, vote);
}
else if (_validatorSet.GetValidator(validatorKey).Power != power)
{
const string msg = "ValidatorPower of the vote is given and the value is " +
"not the same with the one in the validator set";
Expand Down

0 comments on commit 61ffe8c

Please sign in to comment.