mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-13 13:43:30 +00:00
Remove unused function (#4496)
* Remove unused function * Merge branch 'master' into rmunused
This commit is contained in:
parent
3c5d5bfc7b
commit
7f1900e96c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user