From 7f1900e96c98a0ba7033e16ce1351f81fd3be991 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Sat, 11 Jan 2020 11:20:05 +0000 Subject: [PATCH] Remove unused function (#4496) * Remove unused function * Merge branch 'master' into rmunused --- beacon-chain/sync/initial-sync/round_robin.go | 40 ------------------- 1 file changed, 40 deletions(-) diff --git a/beacon-chain/sync/initial-sync/round_robin.go b/beacon-chain/sync/initial-sync/round_robin.go index f1ebb52a485..9588162236c 100644 --- a/beacon-chain/sync/initial-sync/round_robin.go +++ b/beacon-chain/sync/initial-sync/round_robin.go @@ -301,46 +301,6 @@ func (s *Service) highestFinalizedEpoch() uint64 { return epoch } -// bestFinalized returns the highest finalized epoch that is agreed upon by the majority of -// peers. This method may not return the absolute highest finalized, but the finalized epoch in -// which most peers can serve blocks. Ideally, all peers would be reporting the same finalized -// epoch. -// Returns the best finalized root, epoch number, and peers that agree. -func (s *Service) bestFinalized() ([]byte, uint64, []peer.ID) { - finalized := make(map[[32]byte]uint64) - rootToEpoch := make(map[[32]byte]uint64) - for _, pid := range s.p2p.Peers().Connected() { - peerChainState, err := s.p2p.Peers().ChainState(pid) - if err == nil && peerChainState != nil { - r := bytesutil.ToBytes32(peerChainState.FinalizedRoot) - finalized[r]++ - rootToEpoch[r] = peerChainState.FinalizedEpoch - } - } - - var mostVotedFinalizedRoot [32]byte - var mostVotes uint64 - for root, count := range finalized { - if count > mostVotes { - mostVotes = count - mostVotedFinalizedRoot = root - } - } - - var pids []peer.ID - for _, pid := range s.p2p.Peers().Connected() { - peerChainState, err := s.p2p.Peers().ChainState(pid) - if err == nil && peerChainState != nil && peerChainState.FinalizedEpoch >= rootToEpoch[mostVotedFinalizedRoot] { - pids = append(pids, pid) - if len(pids) >= params.BeaconConfig().MaxPeersToSync { - break - } - } - } - - return mostVotedFinalizedRoot[:], rootToEpoch[mostVotedFinalizedRoot], pids -} - // bestPeer returns the peer ID of the peer reporting the highest head slot. func (s *Service) bestPeer() peer.ID { var best peer.ID