From 2bea886e8ea3cc4d970f55ce9a6b1a20ca938fbe Mon Sep 17 00:00:00 2001 From: GheisMohammadi Date: Fri, 4 Oct 2024 17:41:02 +0800 Subject: [PATCH] improve getBlockByMaxVote --- api/service/stagedstreamsync/helpers.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/service/stagedstreamsync/helpers.go b/api/service/stagedstreamsync/helpers.go index afe8a3fa0e..caf5ff5304 100644 --- a/api/service/stagedstreamsync/helpers.go +++ b/api/service/stagedstreamsync/helpers.go @@ -82,6 +82,9 @@ func getBlockByMaxVote(blocks []*types.Block) (*types.Block, error) { if block == nil { continue } + if _, exist := hashesVote[block.Header().Hash()]; !exist { + hashesVote[block.Header().Hash()] = 0 + } hashesVote[block.Header().Hash()]++ if hashesVote[block.Header().Hash()] > maxVote { maxVote = hashesVote[block.Header().Hash()]