From d6cb66ec0ea36830613e73f24cb79e49b27719af Mon Sep 17 00:00:00 2001 From: mrekucci Date: Mon, 6 Nov 2023 19:09:26 +0700 Subject: [PATCH] fix: prioritize QUIC for bootnode connection --- pkg/topology/kademlia/kademlia.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/topology/kademlia/kademlia.go b/pkg/topology/kademlia/kademlia.go index 277eeba331a..d019d374af8 100644 --- a/pkg/topology/kademlia/kademlia.go +++ b/pkg/topology/kademlia/kademlia.go @@ -13,6 +13,8 @@ import ( "math/big" "math/rand" "path/filepath" + "sort" + "strings" "sync" "time" @@ -135,6 +137,11 @@ func newKadOptions(o Options) kadOptions { LowWaterMark: defaultValInt(o.LowWaterMark, defaultLowWaterMark), } + // Prioritize QUIC transport connections over the others. + sort.Slice(ko.Bootnodes, func(i, j int) bool { + return strings.Contains(ko.Bootnodes[i].String(), "/quic") + }) + if ko.SaturationFunc == nil { ko.SaturationFunc = makeSaturationFunc(ko) }