2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-06-22 14:33:57 +01:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package dht
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2019-02-22 18:39:29 +00:00
|
|
|
"time"
|
2018-06-22 14:33:57 +01:00
|
|
|
|
2019-04-22 10:07:50 +01:00
|
|
|
"storj.io/storj/pkg/overlay"
|
2018-09-18 05:39:06 +01:00
|
|
|
"storj.io/storj/pkg/pb"
|
2018-11-29 18:39:27 +00:00
|
|
|
"storj.io/storj/pkg/storj"
|
2019-02-22 18:39:29 +00:00
|
|
|
"storj.io/storj/storage"
|
2018-06-22 14:33:57 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// DHT is the interface for the DHT in the Storj network
|
|
|
|
type DHT interface {
|
2019-04-22 10:07:50 +01:00
|
|
|
FindNear(ctx context.Context, start storj.NodeID, limit int) ([]*pb.Node, error)
|
2018-06-22 14:33:57 +01:00
|
|
|
Bootstrap(ctx context.Context) error
|
2018-09-18 05:39:06 +01:00
|
|
|
Ping(ctx context.Context, node pb.Node) (pb.Node, error)
|
2018-11-29 18:39:27 +00:00
|
|
|
FindNode(ctx context.Context, ID storj.NodeID) (pb.Node, error)
|
2018-11-20 16:54:52 +00:00
|
|
|
Seen() []*pb.Node
|
2018-06-22 14:33:57 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 18:39:29 +00:00
|
|
|
// RoutingTable contains information on nodes we have locally
|
|
|
|
type RoutingTable interface {
|
|
|
|
// local params
|
2019-04-22 10:07:50 +01:00
|
|
|
Local() overlay.NodeDossier
|
2019-02-22 18:39:29 +00:00
|
|
|
K() int
|
|
|
|
CacheSize() int
|
2019-06-13 15:51:50 +01:00
|
|
|
GetBucketIds(context.Context) (storage.Keys, error)
|
|
|
|
FindNear(ctx context.Context, id storj.NodeID, limit int) ([]*pb.Node, error)
|
|
|
|
ConnectionSuccess(ctx context.Context, node *pb.Node) error
|
|
|
|
ConnectionFailed(ctx context.Context, node *pb.Node) error
|
2019-02-22 18:39:29 +00:00
|
|
|
// these are for refreshing
|
2019-06-13 15:51:50 +01:00
|
|
|
SetBucketTimestamp(ctx context.Context, id []byte, now time.Time) error
|
|
|
|
GetBucketTimestamp(ctx context.Context, id []byte) (time.Time, error)
|
2019-02-22 18:39:29 +00:00
|
|
|
|
|
|
|
Close() error
|
|
|
|
}
|
|
|
|
|
2018-06-22 14:33:57 +01:00
|
|
|
// Bucket is a set of methods to act on kademlia k buckets
|
|
|
|
type Bucket interface {
|
2018-09-18 05:39:06 +01:00
|
|
|
Routing() []pb.Node
|
|
|
|
Cache() []pb.Node
|
2018-11-29 18:39:27 +00:00
|
|
|
// TODO: should this be a NodeID?
|
2018-06-22 14:33:57 +01:00
|
|
|
Midpoint() string
|
2018-09-18 05:39:06 +01:00
|
|
|
Nodes() []*pb.Node
|
2018-06-22 14:33:57 +01:00
|
|
|
}
|