diff --git a/p2p/protocol/identify/obsaddr.go b/p2p/protocol/identify/obsaddr.go index ac299a4efe..70a7eccd49 100644 --- a/p2p/protocol/identify/obsaddr.go +++ b/p2p/protocol/identify/obsaddr.go @@ -212,10 +212,13 @@ func (oas *ObservedAddrManager) filter(observedAddrs []*observedAddr) []ma.Multi for pat := range pmap { s := pmap[pat] - // We prefer inbound connection observations over outbound. - // For ties, we prefer the ones with more votes. slices.SortFunc(s, func(first, second *observedAddr) int { - if first.numInbound > second.numInbound || len(first.seenBy) > len(second.seenBy) { + // We prefer inbound connection observations over outbound. + if first.numInbound > second.numInbound { + return -1 + } + // For ties, we prefer the ones with more votes. + if first.numInbound == second.numInbound && len(first.seenBy) > len(second.seenBy) { return -1 } return 1