Skip to content

Commit

Permalink
bitswap: handle dialing to self
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Nov 19, 2024
1 parent 4ccc944 commit 7359d9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions bitswap/network/ipfs_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ func (bsnet *impl) Stop() {
}

func (bsnet *impl) Connect(ctx context.Context, p peer.AddrInfo) error {
if p.ID == bsnet.host.ID() {
return nil
}
return bsnet.host.Connect(ctx, p)
}

Expand Down
3 changes: 2 additions & 1 deletion routing/providerquerymanager/providerquerymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log/v2"
peer "github.com/libp2p/go-libp2p/core/peer"
swarm "github.com/libp2p/go-libp2p/p2p/net/swarm"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -300,7 +301,7 @@ func (pqm *ProviderQueryManager) findProviderWorker() {
defer wg.Done()
span.AddEvent("FoundProvider", trace.WithAttributes(attribute.Stringer("peer", p.ID)))
err := pqm.dialer.Connect(findProviderCtx, p)
if err != nil {
if err != nil && err != swarm.ErrDialToSelf {
span.RecordError(err, trace.WithAttributes(attribute.Stringer("peer", p.ID)))
log.Debugf("failed to connect to provider %s: %s", p.ID, err)
return
Expand Down

0 comments on commit 7359d9f

Please sign in to comment.