Skip to content

Commit 6edcea2

Browse files
authored
Merge pull request #585 from libp2p/fix/optimize-is-relay
fix: optimize isRelay
2 parents 6b94711 + e774f01 commit 6edcea2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

dht_filters.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ func sameV6Net(a, b net.IP) bool {
166166
}
167167

168168
func isRelayAddr(a ma.Multiaddr) bool {
169-
for _, p := range a.Protocols() {
170-
if p.Code == ma.P_CIRCUIT {
171-
return true
172-
}
173-
}
174-
return false
169+
found := false
170+
ma.ForEach(a, func(c ma.Component) bool {
171+
found = c.Protocol().Code == ma.P_CIRCUIT
172+
return !found
173+
})
174+
return found
175175
}

0 commit comments

Comments
 (0)