Skip to content

Commit

Permalink
feat: fix voting sum logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Teja2045 committed Sep 24, 2024
1 parent c2f51f3 commit a414c7f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ func (h *ProofOfBlobProposalHandler) aggregateVotes(ctx sdk.Context, ci abci.Ext
totalVoting := 0

for _, v := range ci.Votes {
totalVoting += int(v.Validator.Power)

// Process only votes with BlockIDFlagCommit, indicating the validator committed to the block.
// Skip votes with other flags (e.g., BlockIDFlagUnknown, BlockIDFlagNil).
if v.BlockIdFlag != cmtproto.BlockIDFlagCommit {
Expand All @@ -215,19 +217,14 @@ func (h *ProofOfBlobProposalHandler) aggregateVotes(ctx sdk.Context, ci abci.Ext
continue
}

currentTotalVoting := 0
for voteRange, isVoted := range voteExt.Votes {

currentTotalVoting += int(v.Validator.Power)
if voteRange != pendingRangeKey || !isVoted {
continue
}

votes[voteRange] += v.Validator.Power
}

totalVoting = max(totalVoting, currentTotalVoting)

}
return votes, int64(totalVoting), nil
}

0 comments on commit a414c7f

Please sign in to comment.