Skip to content

Commit

Permalink
Remove unused function (#4496)
Browse files Browse the repository at this point in the history
* Remove unused function
* Merge branch 'master' into rmunused
  • Loading branch information
mcdee authored and prylabs-bulldozer[bot] committed Jan 11, 2020
1 parent 3c5d5bf commit 7f1900e
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions beacon-chain/sync/initial-sync/round_robin.go
Expand Up @@ -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
Expand Down

0 comments on commit 7f1900e

Please sign in to comment.