From 5e68507d821a427fde7d8dfd1baa1cfb982728c2 Mon Sep 17 00:00:00 2001 From: Dennis Trautwein Date: Tue, 7 Feb 2023 18:08:52 +0100 Subject: [PATCH] Revert "use ping protocol instead of DHT ping" This reverts commit 16823c3a5818ce23c577b2b0c889cd91857f9366. --- dht.go | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/dht.go b/dht.go index ae07fa700..1bb75dfb0 100644 --- a/dht.go +++ b/dht.go @@ -26,7 +26,6 @@ import ( "github.com/libp2p/go-libp2p-kbucket/peerdiversity" record "github.com/libp2p/go-libp2p-record" recpb "github.com/libp2p/go-libp2p-record/pb" - "github.com/libp2p/go-libp2p/p2p/protocol/ping" "github.com/gogo/protobuf/proto" ds "github.com/ipfs/go-datastore" @@ -69,11 +68,6 @@ const ( protectedBuckets = 2 ) -const ( - // MAGIC: timeout for receiving a pong from a peer in our routing table - pingTimeout = 5 * time.Second -) - type addPeerRTReq struct { p peer.ID queryPeer bool @@ -372,19 +366,7 @@ func makeRtRefreshManager(dht *IpfsDHT, cfg dhtcfg.Config, maxLastSuccessfulOutb } pingFnc := func(ctx context.Context, p peer.ID) error { - timeoutCtx, cancel := context.WithTimeout(ctx, pingTimeout) - defer cancel() - - // Just wait for a single ping - select { - case res, more := <-ping.Ping(timeoutCtx, dht.host, p): - if !more { - return timeoutCtx.Err() - } - return res.Error - case <-timeoutCtx.Done(): - return timeoutCtx.Err() - } + return dht.protoMessenger.Ping(ctx, p) } r, err := rtrefresh.NewRtRefreshManager(