From 18f86e6d6e05af56a95539f609bbcfaafc332032 Mon Sep 17 00:00:00 2001 From: gammazero <11790789+gammazero@users.noreply.github.com> Date: Tue, 4 Mar 2025 13:58:07 -1000 Subject: [PATCH] do not use multiple multi-error packages, pick one --- dual/dual.go | 10 ++++------ go.mod | 4 +--- go.sum | 9 ++------- rtrefresh/rt_refresh_manager.go | 8 ++++---- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/dual/dual.go b/dual/dual.go index f3a76de1b..a86d9294d 100644 --- a/dual/dual.go +++ b/dual/dual.go @@ -7,14 +7,13 @@ import ( "fmt" "sync" + "github.com/ipfs/go-cid" dht "github.com/libp2p/go-libp2p-kad-dht" "github.com/libp2p/go-libp2p-kad-dht/internal" - "github.com/libp2p/go-libp2p-routing-helpers/tracing" - - "github.com/ipfs/go-cid" kb "github.com/libp2p/go-libp2p-kbucket" "github.com/libp2p/go-libp2p-kbucket/peerdiversity" helper "github.com/libp2p/go-libp2p-routing-helpers" + "github.com/libp2p/go-libp2p-routing-helpers/tracing" ci "github.com/libp2p/go-libp2p/core/crypto" "github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/peer" @@ -22,8 +21,7 @@ import ( "github.com/libp2p/go-libp2p/core/routing" ma "github.com/multiformats/go-multiaddr" manet "github.com/multiformats/go-multiaddr/net" - - "github.com/hashicorp/go-multierror" + "go.uber.org/multierr" ) const ( @@ -320,7 +318,7 @@ func combineErrors(erra, errb error) error { } else if errb == kb.ErrLookupFailure { return erra } - return multierror.Append(erra, errb).ErrorOrNil() + return multierr.Append(erra, errb) } // Bootstrap allows callers to hint to the routing system to get into a diff --git a/go.mod b/go.mod index f3f2e86f5..af44bfe5b 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.23.0 require ( github.com/google/gopacket v1.1.19 github.com/google/uuid v1.6.0 - github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/golang-lru v1.0.2 github.com/ipfs/boxo v0.28.0 github.com/ipfs/go-cid v0.5.0 @@ -17,7 +16,7 @@ require ( github.com/libp2p/go-libp2p v0.41.0 github.com/libp2p/go-libp2p-kbucket v0.6.5 github.com/libp2p/go-libp2p-record v0.3.1 - github.com/libp2p/go-libp2p-routing-helpers v0.7.4 + github.com/libp2p/go-libp2p-routing-helpers v0.7.5 github.com/libp2p/go-libp2p-testing v0.12.0 github.com/libp2p/go-libp2p-xor v0.1.0 github.com/libp2p/go-msgio v0.3.0 @@ -59,7 +58,6 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/google/pprof v0.0.0-20250208200701-d0013a598941 // indirect github.com/gorilla/websocket v1.5.3 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect github.com/huin/goupnp v1.3.0 // indirect github.com/ipfs/go-block-format v0.2.0 // indirect github.com/ipfs/go-ipfs-util v0.0.3 // indirect diff --git a/go.sum b/go.sum index 30b726587..62ccdaef5 100644 --- a/go.sum +++ b/go.sum @@ -136,11 +136,6 @@ github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:Fecb github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU= github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= @@ -237,8 +232,8 @@ github.com/libp2p/go-libp2p-kbucket v0.6.5/go.mod h1:U6WOd0BvnSp03IQSrjgM54tg7zh github.com/libp2p/go-libp2p-peerstore v0.1.4/go.mod h1:+4BDbDiiKf4PzpANZDAT+knVdLxvqh7hXOujessqdzs= github.com/libp2p/go-libp2p-record v0.3.1 h1:cly48Xi5GjNw5Wq+7gmjfBiG9HCzQVkiZOUZ8kUl+Fg= github.com/libp2p/go-libp2p-record v0.3.1/go.mod h1:T8itUkLcWQLCYMqtX7Th6r7SexyUJpIyPgks757td/E= -github.com/libp2p/go-libp2p-routing-helpers v0.7.4 h1:6LqS1Bzn5CfDJ4tzvP9uwh42IB7TJLNFJA6dEeGBv84= -github.com/libp2p/go-libp2p-routing-helpers v0.7.4/go.mod h1:we5WDj9tbolBXOuF1hGOkR+r7Uh1408tQbAKaT5n1LE= +github.com/libp2p/go-libp2p-routing-helpers v0.7.5 h1:HdwZj9NKovMx0vqq6YNPTh6aaNzey5zHD7HeLJtq6fI= +github.com/libp2p/go-libp2p-routing-helpers v0.7.5/go.mod h1:3YaxrwP0OBPDD7my3D0KxfR89FlcX/IEbxDEDfAmj98= github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA= github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg= github.com/libp2p/go-libp2p-xor v0.1.0 h1:hhQwT4uGrBcuAkUGXADuPltalOdpf9aag9kaYNT2tLA= diff --git a/rtrefresh/rt_refresh_manager.go b/rtrefresh/rt_refresh_manager.go index c81e9e6ed..a3280581a 100644 --- a/rtrefresh/rt_refresh_manager.go +++ b/rtrefresh/rt_refresh_manager.go @@ -7,7 +7,6 @@ import ( "sync/atomic" "time" - "github.com/hashicorp/go-multierror" logging "github.com/ipfs/go-log/v2" "github.com/libp2p/go-libp2p-kad-dht/internal" kbucket "github.com/libp2p/go-libp2p-kbucket" @@ -17,6 +16,7 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/trace" + "go.uber.org/multierr" ) var logger = logging.Logger("dht/RtRefreshManager") @@ -244,7 +244,7 @@ func (r *RtRefreshManager) doRefresh(ctx context.Context, forceRefresh bool) err var merr error if err := r.queryForSelf(ctx); err != nil { - merr = multierror.Append(merr, err) + merr = multierr.Append(merr, err) } refreshCpls := r.rt.GetTrackedCplsForRefresh() @@ -261,7 +261,7 @@ func (r *RtRefreshManager) doRefresh(ctx context.Context, forceRefresh bool) err for c := range refreshCpls { cpl := uint(c) if err := rfnc(cpl); err != nil { - merr = multierror.Append(merr, err) + merr = multierr.Append(merr, err) } else { // If we see a gap at a Cpl in the Routing table, we ONLY refresh up until the maximum cpl we // have in the Routing Table OR (2 * (Cpl+ 1) with the gap), whichever is smaller. @@ -274,7 +274,7 @@ func (r *RtRefreshManager) doRefresh(ctx context.Context, forceRefresh bool) err lastCpl := min(2*(c+1), len(refreshCpls)-1) for i := c + 1; i < lastCpl+1; i++ { if err := rfnc(uint(i)); err != nil { - merr = multierror.Append(merr, err) + merr = multierr.Append(merr, err) } } return merr