Fix param naming in BestNonFinalized (#7693)

This commit is contained in:
Victor Farazdagi 2020-11-01 03:03:44 +03:00 committed by GitHub
parent 926d3b9b34
commit 3584bcba8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -482,19 +482,19 @@ func (p *Status) BestFinalized(maxPeers int, ourFinalizedEpoch uint64) (uint64,
return targetEpoch, potentialPIDs
}
// BestNonFinalized returns the highest known epoch, which is higher than ours, and is shared
// by at least minPeers.
func (p *Status) BestNonFinalized(minPeers int, ourFinalizedEpoch uint64) (uint64, []peer.ID) {
// BestNonFinalized returns the highest known epoch, higher than ours,
// and is shared by at least minPeers.
func (p *Status) BestNonFinalized(minPeers int, ourHeadEpoch uint64) (uint64, []peer.ID) {
connected := p.Connected()
epochVotes := make(map[uint64]uint64)
pidEpoch := make(map[peer.ID]uint64, len(connected))
pidHead := make(map[peer.ID]uint64, len(connected))
potentialPIDs := make([]peer.ID, 0, len(connected))
ourFinalizedSlot := ourFinalizedEpoch * params.BeaconConfig().SlotsPerEpoch
ourHeadSlot := ourHeadEpoch * params.BeaconConfig().SlotsPerEpoch
for _, pid := range connected {
peerChainState, err := p.ChainState(pid)
if err == nil && peerChainState != nil && peerChainState.HeadSlot > ourFinalizedSlot {
if err == nil && peerChainState != nil && peerChainState.HeadSlot > ourHeadSlot {
epoch := helpers.SlotToEpoch(peerChainState.HeadSlot)
epochVotes[epoch]++
pidEpoch[pid] = epoch