From 67aba4d50149406de36e5cc79b381b16ea7debfe Mon Sep 17 00:00:00 2001 From: vyzo Date: Wed, 24 Oct 2018 10:38:15 +0300 Subject: [PATCH] move relay selection strategy out of line --- p2p/host/relay/autorelay.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/p2p/host/relay/autorelay.go b/p2p/host/relay/autorelay.go index f506a0b..9e23527 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() -- GitLab