Skip to content

Commit 5e68507

Browse files
committed
Revert "use ping protocol instead of DHT ping"
This reverts commit 16823c3.
1 parent d5ea78f commit 5e68507

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

dht.go

+1-19
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/libp2p/go-libp2p-kbucket/peerdiversity"
2727
record "github.com/libp2p/go-libp2p-record"
2828
recpb "github.com/libp2p/go-libp2p-record/pb"
29-
"github.com/libp2p/go-libp2p/p2p/protocol/ping"
3029

3130
"github.com/gogo/protobuf/proto"
3231
ds "github.com/ipfs/go-datastore"
@@ -69,11 +68,6 @@ const (
6968
protectedBuckets = 2
7069
)
7170

72-
const (
73-
// MAGIC: timeout for receiving a pong from a peer in our routing table
74-
pingTimeout = 5 * time.Second
75-
)
76-
7771
type addPeerRTReq struct {
7872
p peer.ID
7973
queryPeer bool
@@ -372,19 +366,7 @@ func makeRtRefreshManager(dht *IpfsDHT, cfg dhtcfg.Config, maxLastSuccessfulOutb
372366
}
373367

374368
pingFnc := func(ctx context.Context, p peer.ID) error {
375-
timeoutCtx, cancel := context.WithTimeout(ctx, pingTimeout)
376-
defer cancel()
377-
378-
// Just wait for a single ping
379-
select {
380-
case res, more := <-ping.Ping(timeoutCtx, dht.host, p):
381-
if !more {
382-
return timeoutCtx.Err()
383-
}
384-
return res.Error
385-
case <-timeoutCtx.Done():
386-
return timeoutCtx.Err()
387-
}
369+
return dht.protoMessenger.Ping(ctx, p)
388370
}
389371

390372
r, err := rtrefresh.NewRtRefreshManager(

0 commit comments

Comments
 (0)