From ceaf76e021446dc0bc719230ab44f248582b49fb Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Thu, 5 Nov 2020 14:42:44 -0800 Subject: [PATCH] prevent nil pointer crash --- consensus/quorum/one-node-staked-vote.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/consensus/quorum/one-node-staked-vote.go b/consensus/quorum/one-node-staked-vote.go index f0099f968..e18b99f99 100644 --- a/consensus/quorum/one-node-staked-vote.go +++ b/consensus/quorum/one-node-staked-vote.go @@ -173,9 +173,11 @@ func (v *stakedVoteWeight) computeTotalPowerByMask(mask *bls_cosi.Mask) *numeric for key, i := range mask.PublicsIndex { if enabled, err := mask.IndexEnabled(i); err == nil && enabled { - currentTotal = currentTotal.Add( - v.roster.Voters[key].OverallPercent, - ) + if voter, ok := v.roster.Voters[key]; ok { + currentTotal = currentTotal.Add( + voter.OverallPercent, + ) + } } } return ¤tTotal