Commit f7353aac authored by Aarsh Shah's avatar Aarsh Shah Committed by Steven Allen

reset timer on bucket

parent d53dfd6a
...@@ -21,18 +21,18 @@ import ( ...@@ -21,18 +21,18 @@ import (
"github.com/libp2p/go-libp2p-kad-dht/metrics" "github.com/libp2p/go-libp2p-kad-dht/metrics"
opts "github.com/libp2p/go-libp2p-kad-dht/opts" opts "github.com/libp2p/go-libp2p-kad-dht/opts"
pb "github.com/libp2p/go-libp2p-kad-dht/pb" pb "github.com/libp2p/go-libp2p-kad-dht/pb"
providers "github.com/libp2p/go-libp2p-kad-dht/providers" "github.com/libp2p/go-libp2p-kad-dht/providers"
proto "github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
cid "github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
ds "github.com/ipfs/go-datastore" ds "github.com/ipfs/go-datastore"
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
goprocess "github.com/jbenet/goprocess" "github.com/jbenet/goprocess"
goprocessctx "github.com/jbenet/goprocess/context" "github.com/jbenet/goprocess/context"
kb "github.com/libp2p/go-libp2p-kbucket" kb "github.com/libp2p/go-libp2p-kbucket"
record "github.com/libp2p/go-libp2p-record" "github.com/libp2p/go-libp2p-record"
recpb "github.com/libp2p/go-libp2p-record/pb" recpb "github.com/libp2p/go-libp2p-record/pb"
base32 "github.com/whyrusleeping/base32" "github.com/whyrusleeping/base32"
) )
var logger = logging.Logger("dht") var logger = logging.Logger("dht")
...@@ -307,6 +307,10 @@ func (dht *IpfsDHT) findPeerSingle(ctx context.Context, p peer.ID, id peer.ID) ( ...@@ -307,6 +307,10 @@ func (dht *IpfsDHT) findPeerSingle(ctx context.Context, p peer.ID, id peer.ID) (
resp, err := dht.sendRequest(ctx, p, pmes) resp, err := dht.sendRequest(ctx, p, pmes)
switch err { switch err {
case nil: case nil:
// reset the timer for the k-bucket we just searched in ONLY if there was no error
// so that we can retry during the next bootstrap
bucket := dht.routingTable.BucketForPeer(id)
bucket.ResetLastQueriedAt(time.Now())
return resp, nil return resp, nil
case ErrReadTimeout: case ErrReadTimeout:
logger.Warningf("read timeout: %s %s", p.Pretty(), id) logger.Warningf("read timeout: %s %s", p.Pretty(), id)
......
...@@ -75,7 +75,7 @@ func (dht *IpfsDHT) BootstrapWithConfig(ctx context.Context, cfg BootstrapConfig ...@@ -75,7 +75,7 @@ func (dht *IpfsDHT) BootstrapWithConfig(ctx context.Context, cfg BootstrapConfig
for { for {
err := dht.BootstrapSelf(ctx) err := dht.BootstrapSelf(ctx)
if err != nil { if err != nil {
logger.Warningf("error bootstrapping while querying for self: %s", err) logger.Warningf("error bootstrapping while searching for my self (I'm Too Shallow ?): %s", err)
} }
select { select {
case <-time.After(cfg.SelfQueryInterval): case <-time.After(cfg.SelfQueryInterval):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment