From 61ffe8cd90e5d8b54730a88910f810e3677fb711 Mon Sep 17 00:00:00 2001 From: s2quake Date: Tue, 22 Oct 2024 10:15:00 +0900 Subject: [PATCH] fix: Add exception handling code to HeightVoteSet for votes with null power --- src/Libplanet.Net/Consensus/HeightVoteSet.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Libplanet.Net/Consensus/HeightVoteSet.cs b/src/Libplanet.Net/Consensus/HeightVoteSet.cs index a6eef27c7b5..1ff8cab050d 100644 --- a/src/Libplanet.Net/Consensus/HeightVoteSet.cs +++ b/src/Libplanet.Net/Consensus/HeightVoteSet.cs @@ -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";