Skip to content

Commit

Permalink
Revert "use ping protocol instead of DHT ping"
Browse files Browse the repository at this point in the history
This reverts commit 16823c3.
  • Loading branch information
dennis-tra committed Feb 7, 2023
1 parent d5ea78f commit 5e68507
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 5e68507

Please sign in to comment.