From 18f082eb4c51f207eb9a78e3cbc4341d1a054df0 Mon Sep 17 00:00:00 2001 From: mrekucci Date: Mon, 6 Nov 2023 16:41:18 +0700 Subject: [PATCH] fix: open API spec --- openapi/SwarmCommon.yaml | 4 ++-- pkg/p2p/discover.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openapi/SwarmCommon.yaml b/openapi/SwarmCommon.yaml index 7c5e7992704..5e7ab092b8f 100644 --- a/openapi/SwarmCommon.yaml +++ b/openapi/SwarmCommon.yaml @@ -326,11 +326,11 @@ components: $ref: "#/components/schemas/Address" fullNode: type: boolean - p2pTransport: + underlay: type: array nullable: true items: - type: string + $ref: "SwarmCommon.yaml#/components/schemas/MultiAddress" BlockListedPeers: diff --git a/pkg/p2p/discover.go b/pkg/p2p/discover.go index 80ac15ae483..90b4f4df1e3 100644 --- a/pkg/p2p/discover.go +++ b/pkg/p2p/discover.go @@ -5,11 +5,11 @@ package p2p import ( + "cmp" "context" "errors" "fmt" - "sort" - "strings" + "slices" ma "github.com/multiformats/go-multiaddr" madns "github.com/multiformats/go-multiaddr-dns" @@ -36,9 +36,9 @@ func Discover(ctx context.Context, addr ma.Multiaddr, f func(ma.Multiaddr) (bool return false, errors.New("non-resolvable API endpoint") } - // sort addrs so that quic is tried first - sort.Slice(addrs, func(i, j int) bool { - return strings.Contains(addrs[i].String(), "/quic") + // Prioritize QUIC transport connections over the others. + slices.SortFunc(addrs, func(i, j ma.Multiaddr) int { + return cmp.Compare(i.String(), "/quic") }) for _, addr := range addrs {