removes pingbackTimeout (#1556)

This commit is contained in:
Natalie Villasana 2019-03-22 16:06:57 -04:00 committed by GitHub
parent 297b393dfd
commit 0fa1d536e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 21 deletions

View File

@ -7,7 +7,6 @@ import (
"context"
"net"
"net/http"
"time"
"github.com/zeebo/errs"
"go.uber.org/zap"
@ -136,7 +135,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config Config) (*P
return nil, errs.Combine(err, peer.Close())
}
peer.Kademlia.Endpoint = kademlia.NewEndpoint(peer.Log.Named("kademlia:endpoint"), peer.Kademlia.Service, peer.Kademlia.RoutingTable, 60*time.Second)
peer.Kademlia.Endpoint = kademlia.NewEndpoint(peer.Log.Named("kademlia:endpoint"), peer.Kademlia.Service, peer.Kademlia.RoutingTable)
pb.RegisterNodesServer(peer.Server.GRPC(), peer.Kademlia.Endpoint)
peer.Kademlia.Inspector = kademlia.NewInspector(peer.Kademlia.Service, peer.Identity)

View File

@ -6,7 +6,6 @@ package kademlia
import (
"context"
"sync/atomic"
"time"
"github.com/zeebo/errs"
"go.uber.org/zap"
@ -19,20 +18,18 @@ var EndpointError = errs.Class("kademlia endpoint error")
// Endpoint implements the kademlia Endpoints
type Endpoint struct {
log *zap.Logger
service *Kademlia
routingTable *RoutingTable
connected int32
pingbackTimeout time.Duration
log *zap.Logger
service *Kademlia
routingTable *RoutingTable
connected int32
}
// NewEndpoint returns a new kademlia endpoint
func NewEndpoint(log *zap.Logger, service *Kademlia, routingTable *RoutingTable, pingbackTimeout time.Duration) *Endpoint {
func NewEndpoint(log *zap.Logger, service *Kademlia, routingTable *RoutingTable) *Endpoint {
return &Endpoint{
service: service,
routingTable: routingTable,
log: log,
pingbackTimeout: pingbackTimeout,
service: service,
routingTable: routingTable,
log: log,
}
}
@ -41,9 +38,7 @@ func (endpoint *Endpoint) Query(ctx context.Context, req *pb.QueryRequest) (*pb.
endpoint.service.Queried()
if req.GetPingback() {
timedCtx, cancel := context.WithTimeout(ctx, endpoint.pingbackTimeout)
defer cancel()
endpoint.pingback(timedCtx, req.Sender)
endpoint.pingback(ctx, req.Sender)
}
nodes, err := endpoint.routingTable.FindNear(req.Target.Id, int(req.Limit))

View File

@ -163,7 +163,7 @@ func testNode(ctx *testcontext.Context, name string, t *testing.T, bn []pb.Node)
k, err := newKademlia(logger, pb.NodeType_STORAGE, bn, lis.Addr().String(), nil, fid, ctx.Dir(name), defaultAlpha)
assert.NoError(t, err)
s := NewEndpoint(logger, k, k.routingTable, 60*time.Second)
s := NewEndpoint(logger, k, k.routingTable)
// new ident opts
serverOptions, err := tlsopts.NewOptions(fid, tlsopts.Config{})

View File

@ -12,7 +12,6 @@ import (
"net/smtp"
"os"
"path/filepath"
"time"
"github.com/zeebo/errs"
"go.uber.org/zap"
@ -279,7 +278,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config *Config) (*
return nil, errs.Combine(err, peer.Close())
}
peer.Kademlia.Endpoint = kademlia.NewEndpoint(peer.Log.Named("kademlia:endpoint"), peer.Kademlia.Service, peer.Kademlia.RoutingTable, 60*time.Second)
peer.Kademlia.Endpoint = kademlia.NewEndpoint(peer.Log.Named("kademlia:endpoint"), peer.Kademlia.Service, peer.Kademlia.RoutingTable)
pb.RegisterNodesServer(peer.Server.GRPC(), peer.Kademlia.Endpoint)
peer.Kademlia.Inspector = kademlia.NewInspector(peer.Kademlia.Service, peer.Identity)

View File

@ -5,7 +5,6 @@ package storagenode
import (
"context"
"time"
"github.com/zeebo/errs"
"go.uber.org/zap"
@ -164,7 +163,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config Config) (*P
return nil, errs.Combine(err, peer.Close())
}
peer.Kademlia.Endpoint = kademlia.NewEndpoint(peer.Log.Named("kademlia:endpoint"), peer.Kademlia.Service, peer.Kademlia.RoutingTable, 60*time.Second)
peer.Kademlia.Endpoint = kademlia.NewEndpoint(peer.Log.Named("kademlia:endpoint"), peer.Kademlia.Service, peer.Kademlia.RoutingTable)
pb.RegisterNodesServer(peer.Server.GRPC(), peer.Kademlia.Endpoint)
peer.Kademlia.Inspector = kademlia.NewInspector(peer.Kademlia.Service, peer.Identity)