storj/pkg/dht/dht.go
Bryan White 2a0c4e60d2
preparing for use of customtype gogo extension with NodeID type (#693)
* preparing for use of `customtype` gogo extension with `NodeID` type

* review changes

* preparing for use of `customtype` gogo extension with `NodeID` type

* review changes

* wip

* tests passing

* wip fixing tests

* more wip test fixing

* remove NodeIDList from proto files

* linter fixes

* linter fixes

* linter/review fixes

* more freaking linter fixes

* omg just kill me - linterrrrrrrr

* travis linter, i will muder you and your family in your sleep

* goimports everything - burn in hell travis

* goimports update

* go mod tidy
2018-11-29 19:39:27 +01:00

56 lines
1.4 KiB
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package dht
import (
"context"
"time"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/storj"
"storj.io/storj/storage"
)
// DHT is the interface for the DHT in the Storj network
type DHT interface {
GetNodes(ctx context.Context, start storj.NodeID, limit int, restrictions ...pb.Restriction) ([]*pb.Node, error)
GetRoutingTable(ctx context.Context) (RoutingTable, error)
Bootstrap(ctx context.Context) error
Ping(ctx context.Context, node pb.Node) (pb.Node, error)
FindNode(ctx context.Context, ID storj.NodeID) (pb.Node, error)
Disconnect() error
Seen() []*pb.Node
}
// RoutingTable contains information on nodes we have locally
type RoutingTable interface {
// local params
Local() pb.Node
K() int
CacheSize() int
// Bucket methods
GetBucket(id storj.NodeID) (bucket Bucket, ok bool)
GetBuckets() ([]Bucket, error)
GetBucketIds() (storage.Keys, error)
FindNear(id storj.NodeID, limit int) ([]*pb.Node, error)
ConnectionSuccess(node *pb.Node) error
ConnectionFailed(node *pb.Node) error
// these are for refreshing
SetBucketTimestamp(id []byte, now time.Time) error
GetBucketTimestamp(id []byte, bucket Bucket) (time.Time, error)
}
// Bucket is a set of methods to act on kademlia k buckets
type Bucket interface {
Routing() []pb.Node
Cache() []pb.Node
// TODO: should this be a NodeID?
Midpoint() string
Nodes() []*pb.Node
}