diff --git a/p2p/host/relay/autorelay.go b/p2p/host/relay/autorelay.go index f506a0baaa4ef488e32a97405cc4763a480166c1..9e2352710d9d84f916008a13f95255e0b7841fed 100644 --- a/p2p/host/relay/autorelay.go +++ b/p2p/host/relay/autorelay.go @@ -132,9 +132,7 @@ func (h *AutoRelayHost) findRelays(ctx context.Context) { return } - // TODO better relay selection strategy; this just selects random relays - // but we should probably use ping latency as the selection metric - shuffleRelays(pis) + pis = h.selectRelays(pis) update := 0 @@ -171,6 +169,13 @@ func (h *AutoRelayHost) findRelays(ctx context.Context) { } } +func (h *AutoRelayHost) selectRelays(pis []pstore.PeerInfo) []pstore.PeerInfo { + // TODO better relay selection strategy; this just selects random relays + // but we should probably use ping latency as the selection metric + shuffleRelays(pis) + return pis +} + func (h *AutoRelayHost) updateAddrs() { h.doUpdateAddrs() h.PushIdentify()