From 081efa47e7fcdda2ea659caf34ceb02578e9f903 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 22 May 2024 21:44:52 -0700 Subject: [PATCH] fix: hello: avoid dialing when fetching hello tipset (#12032) We should already be connected to this peer and we're only fetching this tipset opportunistically. If we've already disconnected from them, move on. --- node/hello/hello.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/hello/hello.go b/node/hello/hello.go index cd1645d3e..ef15ece16 100644 --- a/node/hello/hello.go +++ b/node/hello/hello.go @@ -7,6 +7,7 @@ import ( "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log/v2" "github.com/libp2p/go-libp2p/core/host" + "github.com/libp2p/go-libp2p/core/network" inet "github.com/libp2p/go-libp2p/core/network" "github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/protocol" @@ -121,7 +122,10 @@ func (hs *Service) HandleStream(s inet.Stream) { hs.pmgr.AddFilecoinPeer(s.Conn().RemotePeer()) } - ts, err := hs.syncer.FetchTipSet(context.Background(), s.Conn().RemotePeer(), types.NewTipSetKey(hmsg.HeaviestTipSet...)) + // We're trying to fetch the tipset from the peer that just said hello to us. No point in + // triggering any dials. + ctx := network.WithNoDial(context.Background(), "fetching filecoin hello tipset") + ts, err := hs.syncer.FetchTipSet(ctx, s.Conn().RemotePeer(), types.NewTipSetKey(hmsg.HeaviestTipSet...)) if err != nil { log.Errorf("failed to fetch tipset from peer during hello: %+v", err) return