First pass at node restrictions (#146)

* WIP First pass at node restrictions

* adjustments to storage clients

* fix cover

* undo previous import change

* adding copyright

* fix the tests

* check for keys

* moar fixes to tests

* linter

* change how we handle restrictions

* add generated pb.go file

* PR comments addressed

* MockKeyValueStore

* pr comments addressed

* missing )

* past my bedtime

* moar merge issues

* cleanup
This commit is contained in:
Dennis Coyle 2018-08-01 10:15:38 -04:00 committed by GitHub
parent 3ac92a7abd
commit 5de5428d3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 892 additions and 253 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ debug
# vendor
vendor
protos/google/*
# Test redis log and snapshot files
*test_redis-server.log

View File

@ -38,7 +38,7 @@ proto:
build-dev-deps:
go get github.com/golang/protobuf/protoc-gen-go
go get github.com/mattn/goveralls
go get golang.org/x/tools/cmd/cover
go get golang.org/x/tools/cover
go get github.com/modocache/gover
go get github.com/alecthomas/gometalinter
gometalinter --install --force

View File

@ -119,6 +119,15 @@ func (m *MockKeyValueStore) List(startingKey storage.Key, limit storage.Limit) (
return keys, nil
}
// GetAll is a noop to adhere to the interface
func (m *MockKeyValueStore) GetAll(keys storage.Keys) (values storage.Values, err error) {
result := storage.Values{}
for _, v := range keys {
result = append(result, m.Data[v.String()])
}
return result, nil
}
// ReverseList returns either a list of keys for which the MockKeyValueStore has values or an error.
func (m *MockKeyValueStore) ReverseList(startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
//TODO - JJ

View File

@ -18,8 +18,7 @@ type NodeID interface {
// DHT is the interface for the DHT in the Storj network
type DHT interface {
GetNodes(ctx context.Context, start string, limit int) ([]*proto.Node, error)
GetNodes(ctx context.Context, start string, limit int, restrictions ...proto.Restriction) ([]*proto.Node, error)
GetRoutingTable(ctx context.Context) (RoutingTable, error)
Bootstrap(ctx context.Context) error
Ping(ctx context.Context, node proto.Node) (proto.Node, error)

View File

@ -87,8 +87,9 @@ func (k Kademlia) Disconnect() error {
return k.dht.Disconnect()
}
// GetNodes returns all nodes from a starting node up to a maximum limit stored in the local routing table
func (k Kademlia) GetNodes(ctx context.Context, start string, limit int) ([]*proto.Node, error) {
// GetNodes returns all nodes from a starting node up to a maximum limit
// stored in the local routing table limiting the result by the specified restrictions
func (k Kademlia) GetNodes(ctx context.Context, start string, limit int, restrictions ...proto.Restriction) ([]*proto.Node, error) {
if start == "" {
start = k.dht.GetSelfID()
}
@ -97,7 +98,14 @@ func (k Kademlia) GetNodes(ctx context.Context, start string, limit int) ([]*pro
if err != nil {
return []*proto.Node{}, err
}
return convertNetworkNodes(nn), nil
nodes := convertNetworkNodes(nn)
for _, r := range restrictions {
nodes = restrict(r, nodes)
}
return nodes, nil
}
// GetRoutingTable provides the routing table for the Kademlia DHT
@ -241,3 +249,52 @@ func GetIntroNode(id, ip, port string) (*proto.Node, error) {
},
}, nil
}
func restrict(r proto.Restriction, n []*proto.Node) []*proto.Node {
oper := r.GetOperand()
op := r.GetOperator()
val := r.GetValue()
var comp int64
results := []*proto.Node{}
for _, v := range n {
switch oper {
case proto.Restriction_freeBandwidth:
comp = v.GetRestrictions().GetFreeBandwidth()
case proto.Restriction_freeDisk:
comp = v.GetRestrictions().GetFreeDisk()
}
switch op {
case proto.Restriction_EQ:
if comp != val {
results = append(results, v)
continue
}
case proto.Restriction_LT:
if comp < val {
results = append(results, v)
continue
}
case proto.Restriction_LTE:
if comp <= val {
results = append(results, v)
continue
}
case proto.Restriction_GT:
if comp > val {
results = append(results, v)
continue
}
case proto.Restriction_GTE:
if comp >= val {
results = append(results, v)
continue
}
}
}
return results
}

View File

@ -127,15 +127,17 @@ func TestGetNodes(t *testing.T) {
}(dhts)
cases := []struct {
k *Kademlia
start string
limit int
expectedErr error
k *Kademlia
start string
limit int
expectedErr error
restrictions []overlay.Restriction
}{
{
k: newTestKademlia(t, "127.0.0.1", "6000", dhts[rand.Intn(testNetSize)], bootNode),
limit: 10,
expectedErr: nil,
k: newTestKademlia(t, "127.0.0.1", "6000", dhts[rand.Intn(testNetSize)], bootNode),
limit: 10,
expectedErr: nil,
restrictions: []overlay.Restriction{},
},
}
@ -153,7 +155,7 @@ func TestGetNodes(t *testing.T) {
assert.NoError(t, err)
start := rt.Local().Id
nodes, err := v.k.GetNodes(ctx, start, v.limit)
nodes, err := v.k.GetNodes(ctx, start, v.limit, v.restrictions...)
assert.Equal(t, v.expectedErr, err)
assert.Len(t, nodes, v.limit)
v.k.dht.Disconnect()

View File

@ -23,7 +23,7 @@ type MockKademlia struct {
// GetNodes increments the GetNodesCalled field on MockKademlia
// returns the Nodes field on MockKademlia
func (k *MockKademlia) GetNodes(ctx context.Context, start string, limit int) ([]*proto.Node, error) {
func (k *MockKademlia) GetNodes(ctx context.Context, start string, limit int, restrictions ...proto.Restriction) ([]*proto.Node, error) {
return k.Nodes, nil
}

View File

@ -57,7 +57,7 @@ func NewBoltOverlayCache(dbPath string, DHT dht.DHT) (*Cache, error) {
}
// Get looks up the provided nodeID from the redis cache
func (o *Cache) Get(ctx context.Context, key string) (*overlay.NodeAddress, error) {
func (o *Cache) Get(ctx context.Context, key string) (*overlay.Node, error) {
b, err := o.DB.Get([]byte(key))
if err != nil {
return nil, err
@ -67,7 +67,7 @@ func (o *Cache) Get(ctx context.Context, key string) (*overlay.NodeAddress, erro
return nil, nil
}
na := &overlay.NodeAddress{}
na := &overlay.Node{}
if err := proto.Unmarshal(b, na); err != nil {
return nil, err
}
@ -75,8 +75,8 @@ func (o *Cache) Get(ctx context.Context, key string) (*overlay.NodeAddress, erro
return na, nil
}
// Put adds a nodeID to the redis cache with a binary representation of proto defined NodeAddress
func (o *Cache) Put(nodeID string, value overlay.NodeAddress) error {
// Put adds a nodeID to the redis cache with a binary representation of proto defined Node
func (o *Cache) Put(nodeID string, value overlay.Node) error {
data, err := proto.Marshal(&value)
if err != nil {
return err

View File

@ -29,7 +29,7 @@ var (
)
type dbClient int
type responses map[dbClient]*overlay.NodeAddress
type responses map[dbClient]*overlay.Node
type errors map[dbClient]*errs.Class
const (
@ -52,7 +52,7 @@ var (
expectedTimesCalled: 1,
key: "foo",
expectedResponses: func() responses {
na := &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}
na := &overlay.Node{Address: &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
return responses{
mock: na,
bolt: na,
@ -65,7 +65,7 @@ var (
_redis: nil,
},
data: test.KvStore{"foo": func() storage.Value {
na := &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}
na := &overlay.Node{Address: &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -78,7 +78,7 @@ var (
expectedTimesCalled: 1,
key: "error",
expectedResponses: func() responses {
na := &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}
na := &overlay.Node{Address: &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
return responses{
mock: nil,
bolt: na,
@ -91,7 +91,7 @@ var (
_redis: nil,
},
data: test.KvStore{"error": func() storage.Value {
na := &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}
na := &overlay.Node{Address: &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -115,7 +115,7 @@ var (
_redis: nil,
},
data: test.KvStore{"foo": func() storage.Value {
na := &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}
na := &overlay.Node{Address: &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}}
d, err := proto.Marshal(na)
if err != nil {
panic(err)
@ -129,7 +129,7 @@ var (
testID string
expectedTimesCalled int
key string
value overlay.NodeAddress
value overlay.Node
expectedErrors errors
data test.KvStore
}{
@ -137,7 +137,7 @@ var (
testID: "valid Put",
expectedTimesCalled: 1,
key: "foo",
value: overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"},
value: overlay.Node{Id: "foo", Address: &overlay.NodeAddress{Transport: overlay.NodeTransport_TCP, Address: "127.0.0.1:9999"}},
expectedErrors: errors{
mock: nil,
bolt: nil,
@ -230,7 +230,7 @@ func TestRedisPut(t *testing.T) {
v, err := db.Get([]byte(c.key))
assert.NoError(t, err)
na := &overlay.NodeAddress{}
na := &overlay.Node{}
assert.NoError(t, proto.Unmarshal(v, na))
assert.Equal(t, na, &c.value)
@ -266,7 +266,7 @@ func TestBoltPut(t *testing.T) {
v, err := db.Get([]byte(c.key))
assert.NoError(t, err)
na := &overlay.NodeAddress{}
na := &overlay.Node{}
assert.NoError(t, proto.Unmarshal(v, na))
assert.Equal(t, na, &c.value)
@ -305,7 +305,7 @@ func TestMockPut(t *testing.T) {
assert.Equal(t, c.expectedTimesCalled, db.PutCalled)
v := db.Data[c.key]
na := &overlay.NodeAddress{}
na := &overlay.Node{}
assert.NoError(t, proto.Unmarshal(v, na))
assert.Equal(t, na, &c.value)

View File

@ -46,16 +46,16 @@ var _ Client = (*Overlay)(nil)
// Choose implements the client.Choose interface
func (o *Overlay) Choose(ctx context.Context, limit int, space int64) ([]*proto.Node, error) {
// TODO(coyle): We will also need to communicate with the reputation service here
resp, err := o.client.FindStorageNodes(ctx, &proto.FindStorageNodesRequest{})
resp, err := o.client.FindStorageNodes(ctx, &proto.FindStorageNodesRequest{
Opts: &proto.OverlayOptions{Limit: int64(limit), Restrictions: &proto.NodeRestrictions{
FreeDisk: space,
}},
})
if err != nil {
return nil, err
}
nodes := []*proto.Node{}
for _, v := range resp.GetNodes() {
nodes = append(nodes, v)
}
return nodes, nil
return resp.GetNodes(), nil
}
// Lookup provides a Node with the given address

View File

@ -36,7 +36,7 @@ func TestFindStorageNodes(t *testing.T) {
c, err := NewClient(address, grpc.WithInsecure())
assert.NoError(t, err)
r, err := c.FindStorageNodes(context.Background(), &proto.FindStorageNodesRequest{})
r, err := c.FindStorageNodes(context.Background(), &proto.FindStorageNodesRequest{Opts: &proto.OverlayOptions{Limit: 5}})
assert.NoError(t, err)
assert.NotNil(t, r)

View File

@ -5,8 +5,8 @@ package overlay
import (
"context"
"sync"
protob "github.com/gogo/protobuf/proto"
"go.uber.org/zap"
"gopkg.in/spacemonkeygo/monkit.v2"
"storj.io/storj/pkg/dht"
@ -15,10 +15,6 @@ import (
"storj.io/storj/storage"
)
const (
maxNodes = 40
)
// Server implements our overlay RPC service
type Server struct {
dht dht.DHT
@ -37,59 +33,100 @@ func (o *Server) Lookup(ctx context.Context, req *proto.LookupRequest) (*proto.L
}
return &proto.LookupResponse{
Node: &proto.Node{
Id: req.GetNodeID(),
Address: na,
},
Node: na,
}, nil
}
// FindStorageNodes searches the overlay network for nodes that meet the provided requirements
func (o *Server) FindStorageNodes(ctx context.Context, req *proto.FindStorageNodesRequest) (*proto.FindStorageNodesResponse, error) {
// NB: call FilterNodeReputation from node_reputation package to find nodes for storage
keys, err := o.cache.DB.List(nil, storage.Limit(10))
if err != nil {
o.logger.Error("Error listing nodes", zap.Error(err))
return nil, err
func (o *Server) FindStorageNodes(ctx context.Context, req *proto.FindStorageNodesRequest) (resp *proto.FindStorageNodesResponse, err error) {
opts := req.GetOpts()
maxNodes := opts.GetLimit()
restrictions := opts.GetRestrictions()
restrictedBandwidth := restrictions.GetFreeBandwidth()
restrictedSpace := restrictions.GetFreeDisk()
var start storage.Key
result := []*proto.Node{}
for {
var nodes []*proto.Node
nodes, start, err = o.populate(ctx, start, maxNodes, restrictedBandwidth, restrictedSpace)
if err != nil {
return nil, err
}
if len(nodes) <= 0 {
break
}
result = append(result, nodes...)
if len(result) >= int(maxNodes) || start == nil {
break
}
}
if len(keys) > maxNodes {
// TODO(coyle): determine if this is a set value or they user of the api will specify
keys = keys[:maxNodes]
if len(result) > int(maxNodes) {
result = result[:maxNodes]
}
nodes := o.getNodes(ctx, keys)
return &proto.FindStorageNodesResponse{
Nodes: nodes,
Nodes: result,
}, nil
}
func (o *Server) getNodes(ctx context.Context, keys storage.Keys) []*proto.Node {
wg := &sync.WaitGroup{}
ch := make(chan *proto.Node, len(keys))
wg.Add(len(keys))
for _, v := range keys {
go func(ch chan *proto.Node, id string) {
defer wg.Done()
na, err := o.cache.Get(ctx, id)
if err != nil {
o.logger.Error("failed to get key from cache", zap.Error(err))
return
}
ch <- &proto.Node{Id: id, Address: na}
}(ch, v.String())
func (o *Server) getNodes(ctx context.Context, keys storage.Keys) ([]*proto.Node, error) {
values, err := o.cache.DB.GetAll(keys)
if err != nil {
return nil, err
}
wg.Wait()
close(ch)
nodes := []*proto.Node{}
for node := range ch {
nodes = append(nodes, node)
for _, v := range values {
n := &proto.Node{}
if err := protob.Unmarshal(v, n); err != nil {
return nil, err
}
nodes = append(nodes, n)
}
return nodes
return nodes, nil
}
func (o *Server) populate(ctx context.Context, starting storage.Key, maxNodes, restrictedBandwidth, restrictedSpace int64) ([]*proto.Node, storage.Key, error) {
limit := storage.Limit(maxNodes) * 2
keys, err := o.cache.DB.List(nil, limit)
if err != nil {
o.logger.Error("Error listing nodes", zap.Error(err))
return nil, nil, err
}
if len(keys) <= 0 {
o.logger.Info("No Keys returned from List operation")
return []*proto.Node{}, starting, nil
}
result := []*proto.Node{}
nodes, err := o.getNodes(ctx, keys)
if err != nil {
return nil, nil, err
}
for _, v := range nodes {
rest := v.GetRestrictions()
if rest.GetFreeBandwidth() < restrictedBandwidth || rest.GetFreeDisk() < restrictedSpace {
continue
}
result = append(result, v)
}
nextStart := keys[len(keys)-1]
if len(keys) < int(limit) {
nextStart = nil
}
return result, nextStart, nil
}

View File

@ -44,7 +44,7 @@ func NewMockServer(kv test.KvStore) *grpc.Server {
// NewNodeAddressValue provides a convient way to create a storage.Value for testing purposes
func NewNodeAddressValue(t *testing.T, address string) storage.Value {
na := &proto.NodeAddress{Transport: proto.NodeTransport_TCP, Address: address}
na := &proto.Node{Id: "", Address: &proto.NodeAddress{Transport: proto.NodeTransport_TCP, Address: address}}
d, err := protob.Marshal(na)
assert.NoError(t, err)

View File

@ -1,6 +1,3 @@
// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
// Code generated by MockGen. DO NOT EDIT.
// Source: storj.io/storj/storage (interfaces: KeyValueStore)
@ -11,7 +8,6 @@ import (
reflect "reflect"
gomock "github.com/golang/mock/gomock"
storage "storj.io/storj/storage"
)
@ -75,6 +71,19 @@ func (mr *MockKeyValueStoreMockRecorder) Get(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockKeyValueStore)(nil).Get), arg0)
}
// GetAll mocks base method
func (m *MockKeyValueStore) GetAll(arg0 storage.Keys) (storage.Values, error) {
ret := m.ctrl.Call(m, "GetAll", arg0)
ret0, _ := ret[0].(storage.Values)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// GetAll indicates an expected call of GetAll
func (mr *MockKeyValueStoreMockRecorder) GetAll(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAll", reflect.TypeOf((*MockKeyValueStore)(nil).GetAll), arg0)
}
// List mocks base method
func (m *MockKeyValueStore) List(arg0 storage.Key, arg1 storage.Limit) (storage.Keys, error) {
ret := m.ctrl.Call(m, "List", arg0, arg1)
@ -88,16 +97,6 @@ func (mr *MockKeyValueStoreMockRecorder) List(arg0, arg1 interface{}) *gomock.Ca
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockKeyValueStore)(nil).List), arg0, arg1)
}
// ReverseList mocks base method
func (m *MockKeyValueStore) ReverseList(arg0 storage.Key, arg1 storage.Limit) (storage.Keys, error) {
return m.List(arg0, arg1)
}
// ReverseList indicates an expected call of ReverseList
func (mr *MockKeyValueStoreMockRecorder) ReverseList(arg0, arg1 interface{}) *gomock.Call {
return mr.List(arg0, arg1)
}
// Put mocks base method
func (m *MockKeyValueStore) Put(arg0 storage.Key, arg1 storage.Value) error {
ret := m.ctrl.Call(m, "Put", arg0, arg1)
@ -109,3 +108,16 @@ func (m *MockKeyValueStore) Put(arg0 storage.Key, arg1 storage.Value) error {
func (mr *MockKeyValueStoreMockRecorder) Put(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Put", reflect.TypeOf((*MockKeyValueStore)(nil).Put), arg0, arg1)
}
// ReverseList mocks base method
func (m *MockKeyValueStore) ReverseList(arg0 storage.Key, arg1 storage.Limit) (storage.Keys, error) {
ret := m.ctrl.Call(m, "ReverseList", arg0, arg1)
ret0, _ := ret[0].(storage.Keys)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ReverseList indicates an expected call of ReverseList
func (mr *MockKeyValueStoreMockRecorder) ReverseList(arg0, arg1 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReverseList", reflect.TypeOf((*MockKeyValueStore)(nil).ReverseList), arg0, arg1)
}

20
pkg/utils/utils.go Normal file
View File

@ -0,0 +1,20 @@
// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package utils
import (
"bytes"
"encoding/gob"
)
// GetBytes transforms an empty interface type into a byte slice
func GetBytes(key interface{}) ([]byte, error) {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
err := enc.Encode(key)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}

View File

@ -1,31 +1,12 @@
// Code generated by protoc-gen-go.
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: overlay.proto
// DO NOT EDIT!
/*
Package overlay is a generated protocol buffer package.
It is generated from these files:
overlay.proto
It has these top-level messages:
LookupRequest
LookupResponse
FindStorageNodesResponse
FindStorageNodesRequest
NodeAddress
OverlayOptions
NodeRep
Node
QueryRequest
QueryResponse
*/
package overlay
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import google_protobuf "github.com/golang/protobuf/ptypes/duration"
import duration "github.com/golang/protobuf/ptypes/duration"
import (
context "golang.org/x/net/context"
@ -60,17 +41,120 @@ var NodeTransport_value = map[string]int32{
func (x NodeTransport) String() string {
return proto.EnumName(NodeTransport_name, int32(x))
}
func (NodeTransport) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (NodeTransport) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{0}
}
// NodeTyp is an enum of possible node types
type NodeType int32
const (
NodeType_ADMIN NodeType = 0
NodeType_STORAGE NodeType = 1
)
var NodeType_name = map[int32]string{
0: "ADMIN",
1: "STORAGE",
}
var NodeType_value = map[string]int32{
"ADMIN": 0,
"STORAGE": 1,
}
func (x NodeType) String() string {
return proto.EnumName(NodeType_name, int32(x))
}
func (NodeType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{1}
}
type Restriction_Operator int32
const (
Restriction_LT Restriction_Operator = 0
Restriction_EQ Restriction_Operator = 1
Restriction_GT Restriction_Operator = 2
Restriction_LTE Restriction_Operator = 3
Restriction_GTE Restriction_Operator = 4
)
var Restriction_Operator_name = map[int32]string{
0: "LT",
1: "EQ",
2: "GT",
3: "LTE",
4: "GTE",
}
var Restriction_Operator_value = map[string]int32{
"LT": 0,
"EQ": 1,
"GT": 2,
"LTE": 3,
"GTE": 4,
}
func (x Restriction_Operator) String() string {
return proto.EnumName(Restriction_Operator_name, int32(x))
}
func (Restriction_Operator) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{11, 0}
}
type Restriction_Operand int32
const (
Restriction_freeBandwidth Restriction_Operand = 0
Restriction_freeDisk Restriction_Operand = 1
)
var Restriction_Operand_name = map[int32]string{
0: "freeBandwidth",
1: "freeDisk",
}
var Restriction_Operand_value = map[string]int32{
"freeBandwidth": 0,
"freeDisk": 1,
}
func (x Restriction_Operand) String() string {
return proto.EnumName(Restriction_Operand_name, int32(x))
}
func (Restriction_Operand) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{11, 1}
}
// LookupRequest is is request message for the lookup rpc call
type LookupRequest struct {
NodeID string `protobuf:"bytes,1,opt,name=nodeID" json:"nodeID,omitempty"`
NodeID string `protobuf:"bytes,1,opt,name=nodeID" json:"nodeID,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *LookupRequest) Reset() { *m = LookupRequest{} }
func (m *LookupRequest) String() string { return proto.CompactTextString(m) }
func (*LookupRequest) ProtoMessage() {}
func (*LookupRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
func (m *LookupRequest) Reset() { *m = LookupRequest{} }
func (m *LookupRequest) String() string { return proto.CompactTextString(m) }
func (*LookupRequest) ProtoMessage() {}
func (*LookupRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{0}
}
func (m *LookupRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LookupRequest.Unmarshal(m, b)
}
func (m *LookupRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_LookupRequest.Marshal(b, m, deterministic)
}
func (dst *LookupRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_LookupRequest.Merge(dst, src)
}
func (m *LookupRequest) XXX_Size() int {
return xxx_messageInfo_LookupRequest.Size(m)
}
func (m *LookupRequest) XXX_DiscardUnknown() {
xxx_messageInfo_LookupRequest.DiscardUnknown(m)
}
var xxx_messageInfo_LookupRequest proto.InternalMessageInfo
func (m *LookupRequest) GetNodeID() string {
if m != nil {
@ -81,13 +165,35 @@ func (m *LookupRequest) GetNodeID() string {
// LookupResponse is is response message for the lookup rpc call
type LookupResponse struct {
Node *Node `protobuf:"bytes,1,opt,name=node" json:"node,omitempty"`
Node *Node `protobuf:"bytes,1,opt,name=node" json:"node,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *LookupResponse) Reset() { *m = LookupResponse{} }
func (m *LookupResponse) String() string { return proto.CompactTextString(m) }
func (*LookupResponse) ProtoMessage() {}
func (*LookupResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
func (m *LookupResponse) Reset() { *m = LookupResponse{} }
func (m *LookupResponse) String() string { return proto.CompactTextString(m) }
func (*LookupResponse) ProtoMessage() {}
func (*LookupResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{1}
}
func (m *LookupResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_LookupResponse.Unmarshal(m, b)
}
func (m *LookupResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_LookupResponse.Marshal(b, m, deterministic)
}
func (dst *LookupResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_LookupResponse.Merge(dst, src)
}
func (m *LookupResponse) XXX_Size() int {
return xxx_messageInfo_LookupResponse.Size(m)
}
func (m *LookupResponse) XXX_DiscardUnknown() {
xxx_messageInfo_LookupResponse.DiscardUnknown(m)
}
var xxx_messageInfo_LookupResponse proto.InternalMessageInfo
func (m *LookupResponse) GetNode() *Node {
if m != nil {
@ -98,13 +204,35 @@ func (m *LookupResponse) GetNode() *Node {
// FindStorageNodesResponse is is response message for the FindStorageNodes rpc call
type FindStorageNodesResponse struct {
Nodes []*Node `protobuf:"bytes,1,rep,name=nodes" json:"nodes,omitempty"`
Nodes []*Node `protobuf:"bytes,1,rep,name=nodes" json:"nodes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *FindStorageNodesResponse) Reset() { *m = FindStorageNodesResponse{} }
func (m *FindStorageNodesResponse) String() string { return proto.CompactTextString(m) }
func (*FindStorageNodesResponse) ProtoMessage() {}
func (*FindStorageNodesResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
func (m *FindStorageNodesResponse) Reset() { *m = FindStorageNodesResponse{} }
func (m *FindStorageNodesResponse) String() string { return proto.CompactTextString(m) }
func (*FindStorageNodesResponse) ProtoMessage() {}
func (*FindStorageNodesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{2}
}
func (m *FindStorageNodesResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FindStorageNodesResponse.Unmarshal(m, b)
}
func (m *FindStorageNodesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_FindStorageNodesResponse.Marshal(b, m, deterministic)
}
func (dst *FindStorageNodesResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_FindStorageNodesResponse.Merge(dst, src)
}
func (m *FindStorageNodesResponse) XXX_Size() int {
return xxx_messageInfo_FindStorageNodesResponse.Size(m)
}
func (m *FindStorageNodesResponse) XXX_DiscardUnknown() {
xxx_messageInfo_FindStorageNodesResponse.DiscardUnknown(m)
}
var xxx_messageInfo_FindStorageNodesResponse proto.InternalMessageInfo
func (m *FindStorageNodesResponse) GetNodes() []*Node {
if m != nil {
@ -115,15 +243,37 @@ func (m *FindStorageNodesResponse) GetNodes() []*Node {
// FindStorageNodesRequest is is request message for the FindStorageNodes rpc call
type FindStorageNodesRequest struct {
ObjectSize int64 `protobuf:"varint,1,opt,name=objectSize" json:"objectSize,omitempty"`
ContractLength *google_protobuf.Duration `protobuf:"bytes,2,opt,name=contractLength" json:"contractLength,omitempty"`
Opts *OverlayOptions `protobuf:"bytes,3,opt,name=opts" json:"opts,omitempty"`
ObjectSize int64 `protobuf:"varint,1,opt,name=objectSize" json:"objectSize,omitempty"`
ContractLength *duration.Duration `protobuf:"bytes,2,opt,name=contractLength" json:"contractLength,omitempty"`
Opts *OverlayOptions `protobuf:"bytes,3,opt,name=opts" json:"opts,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *FindStorageNodesRequest) Reset() { *m = FindStorageNodesRequest{} }
func (m *FindStorageNodesRequest) String() string { return proto.CompactTextString(m) }
func (*FindStorageNodesRequest) ProtoMessage() {}
func (*FindStorageNodesRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
func (m *FindStorageNodesRequest) Reset() { *m = FindStorageNodesRequest{} }
func (m *FindStorageNodesRequest) String() string { return proto.CompactTextString(m) }
func (*FindStorageNodesRequest) ProtoMessage() {}
func (*FindStorageNodesRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{3}
}
func (m *FindStorageNodesRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_FindStorageNodesRequest.Unmarshal(m, b)
}
func (m *FindStorageNodesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_FindStorageNodesRequest.Marshal(b, m, deterministic)
}
func (dst *FindStorageNodesRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_FindStorageNodesRequest.Merge(dst, src)
}
func (m *FindStorageNodesRequest) XXX_Size() int {
return xxx_messageInfo_FindStorageNodesRequest.Size(m)
}
func (m *FindStorageNodesRequest) XXX_DiscardUnknown() {
xxx_messageInfo_FindStorageNodesRequest.DiscardUnknown(m)
}
var xxx_messageInfo_FindStorageNodesRequest proto.InternalMessageInfo
func (m *FindStorageNodesRequest) GetObjectSize() int64 {
if m != nil {
@ -132,7 +282,7 @@ func (m *FindStorageNodesRequest) GetObjectSize() int64 {
return 0
}
func (m *FindStorageNodesRequest) GetContractLength() *google_protobuf.Duration {
func (m *FindStorageNodesRequest) GetContractLength() *duration.Duration {
if m != nil {
return m.ContractLength
}
@ -148,14 +298,36 @@ func (m *FindStorageNodesRequest) GetOpts() *OverlayOptions {
// NodeAddress contains the information needed to communicate with a node on the network
type NodeAddress struct {
Transport NodeTransport `protobuf:"varint,1,opt,name=transport,enum=overlay.NodeTransport" json:"transport,omitempty"`
Address string `protobuf:"bytes,2,opt,name=address" json:"address,omitempty"`
Transport NodeTransport `protobuf:"varint,1,opt,name=transport,enum=overlay.NodeTransport" json:"transport,omitempty"`
Address string `protobuf:"bytes,2,opt,name=address" json:"address,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *NodeAddress) Reset() { *m = NodeAddress{} }
func (m *NodeAddress) String() string { return proto.CompactTextString(m) }
func (*NodeAddress) ProtoMessage() {}
func (*NodeAddress) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func (m *NodeAddress) Reset() { *m = NodeAddress{} }
func (m *NodeAddress) String() string { return proto.CompactTextString(m) }
func (*NodeAddress) ProtoMessage() {}
func (*NodeAddress) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{4}
}
func (m *NodeAddress) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NodeAddress.Unmarshal(m, b)
}
func (m *NodeAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NodeAddress.Marshal(b, m, deterministic)
}
func (dst *NodeAddress) XXX_Merge(src proto.Message) {
xxx_messageInfo_NodeAddress.Merge(dst, src)
}
func (m *NodeAddress) XXX_Size() int {
return xxx_messageInfo_NodeAddress.Size(m)
}
func (m *NodeAddress) XXX_DiscardUnknown() {
xxx_messageInfo_NodeAddress.DiscardUnknown(m)
}
var xxx_messageInfo_NodeAddress proto.InternalMessageInfo
func (m *NodeAddress) GetTransport() NodeTransport {
if m != nil {
@ -173,18 +345,41 @@ func (m *NodeAddress) GetAddress() string {
// OverlayOptions is a set of criteria that a node must meet to be considered for a storage opportunity
type OverlayOptions struct {
MaxLatency *google_protobuf.Duration `protobuf:"bytes,1,opt,name=maxLatency" json:"maxLatency,omitempty"`
MinReputation *NodeRep `protobuf:"bytes,2,opt,name=minReputation" json:"minReputation,omitempty"`
MinSpeedKbps int64 `protobuf:"varint,3,opt,name=minSpeedKbps" json:"minSpeedKbps,omitempty"`
Limit int64 `protobuf:"varint,4,opt,name=limit" json:"limit,omitempty"`
MaxLatency *duration.Duration `protobuf:"bytes,1,opt,name=maxLatency" json:"maxLatency,omitempty"`
MinReputation *NodeRep `protobuf:"bytes,2,opt,name=minReputation" json:"minReputation,omitempty"`
MinSpeedKbps int64 `protobuf:"varint,3,opt,name=minSpeedKbps" json:"minSpeedKbps,omitempty"`
Limit int64 `protobuf:"varint,4,opt,name=limit" json:"limit,omitempty"`
Restrictions *NodeRestrictions `protobuf:"bytes,5,opt,name=restrictions" json:"restrictions,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *OverlayOptions) Reset() { *m = OverlayOptions{} }
func (m *OverlayOptions) String() string { return proto.CompactTextString(m) }
func (*OverlayOptions) ProtoMessage() {}
func (*OverlayOptions) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
func (m *OverlayOptions) Reset() { *m = OverlayOptions{} }
func (m *OverlayOptions) String() string { return proto.CompactTextString(m) }
func (*OverlayOptions) ProtoMessage() {}
func (*OverlayOptions) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{5}
}
func (m *OverlayOptions) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_OverlayOptions.Unmarshal(m, b)
}
func (m *OverlayOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_OverlayOptions.Marshal(b, m, deterministic)
}
func (dst *OverlayOptions) XXX_Merge(src proto.Message) {
xxx_messageInfo_OverlayOptions.Merge(dst, src)
}
func (m *OverlayOptions) XXX_Size() int {
return xxx_messageInfo_OverlayOptions.Size(m)
}
func (m *OverlayOptions) XXX_DiscardUnknown() {
xxx_messageInfo_OverlayOptions.DiscardUnknown(m)
}
func (m *OverlayOptions) GetMaxLatency() *google_protobuf.Duration {
var xxx_messageInfo_OverlayOptions proto.InternalMessageInfo
func (m *OverlayOptions) GetMaxLatency() *duration.Duration {
if m != nil {
return m.MaxLatency
}
@ -212,25 +407,125 @@ func (m *OverlayOptions) GetLimit() int64 {
return 0
}
// NodeRep is the reputation characteristics of a node
type NodeRep struct {
func (m *OverlayOptions) GetRestrictions() *NodeRestrictions {
if m != nil {
return m.Restrictions
}
return nil
}
func (m *NodeRep) Reset() { *m = NodeRep{} }
func (m *NodeRep) String() string { return proto.CompactTextString(m) }
func (*NodeRep) ProtoMessage() {}
func (*NodeRep) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
// NodeRep is the reputation characteristics of a node
type NodeRep struct {
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *NodeRep) Reset() { *m = NodeRep{} }
func (m *NodeRep) String() string { return proto.CompactTextString(m) }
func (*NodeRep) ProtoMessage() {}
func (*NodeRep) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{6}
}
func (m *NodeRep) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NodeRep.Unmarshal(m, b)
}
func (m *NodeRep) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NodeRep.Marshal(b, m, deterministic)
}
func (dst *NodeRep) XXX_Merge(src proto.Message) {
xxx_messageInfo_NodeRep.Merge(dst, src)
}
func (m *NodeRep) XXX_Size() int {
return xxx_messageInfo_NodeRep.Size(m)
}
func (m *NodeRep) XXX_DiscardUnknown() {
xxx_messageInfo_NodeRep.DiscardUnknown(m)
}
var xxx_messageInfo_NodeRep proto.InternalMessageInfo
// NodeRestrictions contains all relevant data about a nodes ability to store data
type NodeRestrictions struct {
FreeBandwidth int64 `protobuf:"varint,1,opt,name=freeBandwidth" json:"freeBandwidth,omitempty"`
FreeDisk int64 `protobuf:"varint,2,opt,name=freeDisk" json:"freeDisk,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *NodeRestrictions) Reset() { *m = NodeRestrictions{} }
func (m *NodeRestrictions) String() string { return proto.CompactTextString(m) }
func (*NodeRestrictions) ProtoMessage() {}
func (*NodeRestrictions) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{7}
}
func (m *NodeRestrictions) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_NodeRestrictions.Unmarshal(m, b)
}
func (m *NodeRestrictions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_NodeRestrictions.Marshal(b, m, deterministic)
}
func (dst *NodeRestrictions) XXX_Merge(src proto.Message) {
xxx_messageInfo_NodeRestrictions.Merge(dst, src)
}
func (m *NodeRestrictions) XXX_Size() int {
return xxx_messageInfo_NodeRestrictions.Size(m)
}
func (m *NodeRestrictions) XXX_DiscardUnknown() {
xxx_messageInfo_NodeRestrictions.DiscardUnknown(m)
}
var xxx_messageInfo_NodeRestrictions proto.InternalMessageInfo
func (m *NodeRestrictions) GetFreeBandwidth() int64 {
if m != nil {
return m.FreeBandwidth
}
return 0
}
func (m *NodeRestrictions) GetFreeDisk() int64 {
if m != nil {
return m.FreeDisk
}
return 0
}
// Node represents a node in the overlay network
type Node struct {
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
Address *NodeAddress `protobuf:"bytes,2,opt,name=address" json:"address,omitempty"`
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
Address *NodeAddress `protobuf:"bytes,2,opt,name=address" json:"address,omitempty"`
Type NodeType `protobuf:"varint,3,opt,name=type,enum=overlay.NodeType" json:"type,omitempty"`
Restrictions *NodeRestrictions `protobuf:"bytes,4,opt,name=restrictions" json:"restrictions,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Node) Reset() { *m = Node{} }
func (m *Node) String() string { return proto.CompactTextString(m) }
func (*Node) ProtoMessage() {}
func (*Node) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
func (m *Node) Reset() { *m = Node{} }
func (m *Node) String() string { return proto.CompactTextString(m) }
func (*Node) ProtoMessage() {}
func (*Node) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{8}
}
func (m *Node) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Node.Unmarshal(m, b)
}
func (m *Node) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Node.Marshal(b, m, deterministic)
}
func (dst *Node) XXX_Merge(src proto.Message) {
xxx_messageInfo_Node.Merge(dst, src)
}
func (m *Node) XXX_Size() int {
return xxx_messageInfo_Node.Size(m)
}
func (m *Node) XXX_DiscardUnknown() {
xxx_messageInfo_Node.DiscardUnknown(m)
}
var xxx_messageInfo_Node proto.InternalMessageInfo
func (m *Node) GetId() string {
if m != nil {
@ -246,15 +541,51 @@ func (m *Node) GetAddress() *NodeAddress {
return nil
}
type QueryRequest struct {
Sender *Node `protobuf:"bytes,1,opt,name=sender" json:"sender,omitempty"`
Receiver *Node `protobuf:"bytes,2,opt,name=receiver" json:"receiver,omitempty"`
func (m *Node) GetType() NodeType {
if m != nil {
return m.Type
}
return NodeType_ADMIN
}
func (m *QueryRequest) Reset() { *m = QueryRequest{} }
func (m *QueryRequest) String() string { return proto.CompactTextString(m) }
func (*QueryRequest) ProtoMessage() {}
func (*QueryRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
func (m *Node) GetRestrictions() *NodeRestrictions {
if m != nil {
return m.Restrictions
}
return nil
}
type QueryRequest struct {
Sender *Node `protobuf:"bytes,1,opt,name=sender" json:"sender,omitempty"`
Receiver *Node `protobuf:"bytes,2,opt,name=receiver" json:"receiver,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *QueryRequest) Reset() { *m = QueryRequest{} }
func (m *QueryRequest) String() string { return proto.CompactTextString(m) }
func (*QueryRequest) ProtoMessage() {}
func (*QueryRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{9}
}
func (m *QueryRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QueryRequest.Unmarshal(m, b)
}
func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_QueryRequest.Marshal(b, m, deterministic)
}
func (dst *QueryRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryRequest.Merge(dst, src)
}
func (m *QueryRequest) XXX_Size() int {
return xxx_messageInfo_QueryRequest.Size(m)
}
func (m *QueryRequest) XXX_DiscardUnknown() {
xxx_messageInfo_QueryRequest.DiscardUnknown(m)
}
var xxx_messageInfo_QueryRequest proto.InternalMessageInfo
func (m *QueryRequest) GetSender() *Node {
if m != nil {
@ -271,14 +602,36 @@ func (m *QueryRequest) GetReceiver() *Node {
}
type QueryResponse struct {
Sender *Node `protobuf:"bytes,1,opt,name=sender" json:"sender,omitempty"`
Response []*Node `protobuf:"bytes,2,rep,name=response" json:"response,omitempty"`
Sender *Node `protobuf:"bytes,1,opt,name=sender" json:"sender,omitempty"`
Response []*Node `protobuf:"bytes,2,rep,name=response" json:"response,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *QueryResponse) Reset() { *m = QueryResponse{} }
func (m *QueryResponse) String() string { return proto.CompactTextString(m) }
func (*QueryResponse) ProtoMessage() {}
func (*QueryResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
func (m *QueryResponse) Reset() { *m = QueryResponse{} }
func (m *QueryResponse) String() string { return proto.CompactTextString(m) }
func (*QueryResponse) ProtoMessage() {}
func (*QueryResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{10}
}
func (m *QueryResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_QueryResponse.Unmarshal(m, b)
}
func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_QueryResponse.Marshal(b, m, deterministic)
}
func (dst *QueryResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_QueryResponse.Merge(dst, src)
}
func (m *QueryResponse) XXX_Size() int {
return xxx_messageInfo_QueryResponse.Size(m)
}
func (m *QueryResponse) XXX_DiscardUnknown() {
xxx_messageInfo_QueryResponse.DiscardUnknown(m)
}
var xxx_messageInfo_QueryResponse proto.InternalMessageInfo
func (m *QueryResponse) GetSender() *Node {
if m != nil {
@ -294,6 +647,60 @@ func (m *QueryResponse) GetResponse() []*Node {
return nil
}
type Restriction struct {
Operator Restriction_Operator `protobuf:"varint,1,opt,name=operator,enum=overlay.Restriction_Operator" json:"operator,omitempty"`
Operand Restriction_Operand `protobuf:"varint,2,opt,name=operand,enum=overlay.Restriction_Operand" json:"operand,omitempty"`
Value int64 `protobuf:"varint,3,opt,name=value" json:"value,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Restriction) Reset() { *m = Restriction{} }
func (m *Restriction) String() string { return proto.CompactTextString(m) }
func (*Restriction) ProtoMessage() {}
func (*Restriction) Descriptor() ([]byte, []int) {
return fileDescriptor_overlay_76f155a132105757, []int{11}
}
func (m *Restriction) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Restriction.Unmarshal(m, b)
}
func (m *Restriction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Restriction.Marshal(b, m, deterministic)
}
func (dst *Restriction) XXX_Merge(src proto.Message) {
xxx_messageInfo_Restriction.Merge(dst, src)
}
func (m *Restriction) XXX_Size() int {
return xxx_messageInfo_Restriction.Size(m)
}
func (m *Restriction) XXX_DiscardUnknown() {
xxx_messageInfo_Restriction.DiscardUnknown(m)
}
var xxx_messageInfo_Restriction proto.InternalMessageInfo
func (m *Restriction) GetOperator() Restriction_Operator {
if m != nil {
return m.Operator
}
return Restriction_LT
}
func (m *Restriction) GetOperand() Restriction_Operand {
if m != nil {
return m.Operand
}
return Restriction_freeBandwidth
}
func (m *Restriction) GetValue() int64 {
if m != nil {
return m.Value
}
return 0
}
func init() {
proto.RegisterType((*LookupRequest)(nil), "overlay.LookupRequest")
proto.RegisterType((*LookupResponse)(nil), "overlay.LookupResponse")
@ -302,10 +709,15 @@ func init() {
proto.RegisterType((*NodeAddress)(nil), "overlay.NodeAddress")
proto.RegisterType((*OverlayOptions)(nil), "overlay.OverlayOptions")
proto.RegisterType((*NodeRep)(nil), "overlay.NodeRep")
proto.RegisterType((*NodeRestrictions)(nil), "overlay.NodeRestrictions")
proto.RegisterType((*Node)(nil), "overlay.Node")
proto.RegisterType((*QueryRequest)(nil), "overlay.QueryRequest")
proto.RegisterType((*QueryResponse)(nil), "overlay.QueryResponse")
proto.RegisterType((*Restriction)(nil), "overlay.Restriction")
proto.RegisterEnum("overlay.NodeTransport", NodeTransport_name, NodeTransport_value)
proto.RegisterEnum("overlay.NodeType", NodeType_name, NodeType_value)
proto.RegisterEnum("overlay.Restriction_Operator", Restriction_Operator_name, Restriction_Operator_value)
proto.RegisterEnum("overlay.Restriction_Operand", Restriction_Operand_name, Restriction_Operand_value)
}
// Reference imports to suppress errors if they are not otherwise used.
@ -316,8 +728,9 @@ var _ grpc.ClientConn
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// Client API for Overlay service
// OverlayClient is the client API for Overlay service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type OverlayClient interface {
// Lookup finds a nodes address from the network
Lookup(ctx context.Context, in *LookupRequest, opts ...grpc.CallOption) (*LookupResponse, error)
@ -335,7 +748,7 @@ func NewOverlayClient(cc *grpc.ClientConn) OverlayClient {
func (c *overlayClient) Lookup(ctx context.Context, in *LookupRequest, opts ...grpc.CallOption) (*LookupResponse, error) {
out := new(LookupResponse)
err := grpc.Invoke(ctx, "/overlay.Overlay/Lookup", in, out, c.cc, opts...)
err := c.cc.Invoke(ctx, "/overlay.Overlay/Lookup", in, out, opts...)
if err != nil {
return nil, err
}
@ -344,15 +757,14 @@ func (c *overlayClient) Lookup(ctx context.Context, in *LookupRequest, opts ...g
func (c *overlayClient) FindStorageNodes(ctx context.Context, in *FindStorageNodesRequest, opts ...grpc.CallOption) (*FindStorageNodesResponse, error) {
out := new(FindStorageNodesResponse)
err := grpc.Invoke(ctx, "/overlay.Overlay/FindStorageNodes", in, out, c.cc, opts...)
err := c.cc.Invoke(ctx, "/overlay.Overlay/FindStorageNodes", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Overlay service
// OverlayServer is the server API for Overlay service.
type OverlayServer interface {
// Lookup finds a nodes address from the network
Lookup(context.Context, *LookupRequest) (*LookupResponse, error)
@ -417,8 +829,9 @@ var _Overlay_serviceDesc = grpc.ServiceDesc{
Metadata: "overlay.proto",
}
// Client API for Nodes service
// NodesClient is the client API for Nodes service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type NodesClient interface {
Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error)
}
@ -433,15 +846,14 @@ func NewNodesClient(cc *grpc.ClientConn) NodesClient {
func (c *nodesClient) Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) {
out := new(QueryResponse)
err := grpc.Invoke(ctx, "/overlay.Nodes/Query", in, out, c.cc, opts...)
err := c.cc.Invoke(ctx, "/overlay.Nodes/Query", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Nodes service
// NodesServer is the server API for Nodes service.
type NodesServer interface {
Query(context.Context, *QueryRequest) (*QueryResponse, error)
}
@ -481,43 +893,56 @@ var _Nodes_serviceDesc = grpc.ServiceDesc{
Metadata: "overlay.proto",
}
func init() { proto.RegisterFile("overlay.proto", fileDescriptor0) }
func init() { proto.RegisterFile("overlay.proto", fileDescriptor_overlay_76f155a132105757) }
var fileDescriptor0 = []byte{
// 546 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x53, 0xed, 0x6e, 0xd3, 0x30,
0x14, 0x25, 0xfd, 0xa4, 0xb7, 0x4b, 0x55, 0x59, 0xa3, 0x0d, 0xfd, 0x31, 0x75, 0x41, 0x88, 0x2f,
0x29, 0x93, 0x3a, 0x34, 0x69, 0xbf, 0xa6, 0x89, 0x69, 0x12, 0xa2, 0x62, 0xe0, 0x4e, 0xe2, 0x17,
0x12, 0x69, 0x73, 0x29, 0x81, 0xd6, 0x0e, 0xb6, 0x33, 0x51, 0xde, 0x85, 0x07, 0xe0, 0x21, 0x78,
0x37, 0x14, 0xdb, 0x49, 0x9b, 0x76, 0x4c, 0xe2, 0x57, 0xe2, 0x7b, 0xce, 0xbd, 0x3e, 0x3e, 0x3e,
0x06, 0x97, 0xdf, 0xa0, 0x58, 0x84, 0xab, 0x20, 0x11, 0x5c, 0x71, 0xd2, 0xb4, 0xcb, 0xc1, 0xc1,
0x9c, 0xf3, 0xf9, 0x02, 0x8f, 0x74, 0x79, 0x9a, 0x7e, 0x3e, 0x8a, 0x52, 0x11, 0xaa, 0x98, 0x33,
0x43, 0xf4, 0x9f, 0x80, 0x3b, 0xe6, 0xfc, 0x5b, 0x9a, 0x50, 0xfc, 0x9e, 0xa2, 0x54, 0xa4, 0x07,
0x0d, 0xc6, 0x23, 0x7c, 0x7d, 0xe1, 0x39, 0x43, 0xe7, 0x69, 0x8b, 0xda, 0x95, 0x7f, 0x0c, 0x9d,
0x9c, 0x28, 0x13, 0xce, 0x24, 0x92, 0x43, 0xa8, 0x65, 0x98, 0xe6, 0xb5, 0x47, 0x6e, 0x90, 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x19, 0x3d, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x07, 0x3b, 0x06, 0x74, 0xbd, 0x04,
0x00, 0x00,
var fileDescriptor_overlay_76f155a132105757 = []byte{
// 759 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xdd, 0x6e, 0xda, 0x48,
0x14, 0xc6, 0xfc, 0x19, 0x0e, 0x60, 0x39, 0xa3, 0x6c, 0xe2, 0x45, 0xbb, 0xab, 0xc4, 0xbb, 0xd1,
0xee, 0x66, 0x25, 0x2e, 0x48, 0x14, 0x29, 0x17, 0xab, 0x88, 0x16, 0x1a, 0x45, 0xa5, 0xa1, 0x19,
0x2c, 0xf5, 0xaa, 0x52, 0x0d, 0x9e, 0x10, 0x37, 0xe0, 0x71, 0xc7, 0x43, 0x5a, 0xfa, 0x2e, 0x7d,
0x80, 0x4a, 0x7d, 0xc0, 0x5e, 0xf4, 0xa2, 0xf2, 0xcc, 0xd8, 0x60, 0x48, 0x22, 0xe5, 0xca, 0x3e,
0xe7, 0xfb, 0xce, 0xff, 0x99, 0x03, 0x0d, 0x7a, 0x47, 0xd8, 0xd4, 0x5d, 0xb4, 0x42, 0x46, 0x39,
0x45, 0xba, 0x12, 0x9b, 0x86, 0x37, 0x67, 0x2e, 0xf7, 0x69, 0x20, 0x01, 0xfb, 0x6f, 0x68, 0xf4,
0x29, 0xbd, 0x9d, 0x87, 0x98, 0x7c, 0x98, 0x93, 0x88, 0xa3, 0x1d, 0x28, 0x07, 0xd4, 0x23, 0x17,
0x5d, 0x4b, 0xdb, 0xd3, 0xfe, 0xa9, 0x62, 0x25, 0xd9, 0x47, 0x60, 0x24, 0xc4, 0x28, 0xa4, 0x41,
0x44, 0xd0, 0x3e, 0x14, 0x63, 0x4c, 0xf0, 0x6a, 0xed, 0x46, 0x2b, 0x89, 0x78, 0x49, 0x3d, 0x82,
0x05, 0x64, 0x9f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xf6,
0x19, 0x94, 0xa4, 0xb7, 0x13, 0x28, 0x89, 0x25, 0x42, 0xbf, 0xa4, 0x46, 0xab, 0x6b, 0xdb, 0xdc,
0x59, 0x57, 0x4b, 0x07, 0xa3, 0xb2, 0x38, 0x5f, 0x47, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x25,
0xbd, 0x2d, 0xae, 0xc8, 0x06, 0x00, 0x00,
}

View File

@ -58,15 +58,30 @@ message OverlayOptions {
NodeRep minReputation = 2; // Not sure what NodeRep is yet.
int64 minSpeedKbps = 3;
int64 limit = 4;
NodeRestrictions restrictions = 5;
}
// NodeRep is the reputation characteristics of a node
message NodeRep {}
// NodeRestrictions contains all relevant data about a nodes ability to store data
message NodeRestrictions {
int64 freeBandwidth = 1;
int64 freeDisk = 2;
}
// Node represents a node in the overlay network
message Node {
string id = 1;
NodeAddress address = 2;
NodeType type = 3;
NodeRestrictions restrictions = 4;
}
// NodeTyp is an enum of possible node types
enum NodeType {
ADMIN = 0;
STORAGE = 1;
}
message QueryRequest {
@ -76,5 +91,24 @@ message QueryRequest {
message QueryResponse {
overlay.Node sender = 1;
repeated overlay.Node response = 2;
}
message Restriction {
enum Operator {
LT = 0;
EQ = 1;
GT = 2;
LTE = 3;
GTE = 4;
}
enum Operand {
freeBandwidth = 0;
freeDisk = 1;
}
Operator operator = 1;
Operand operand = 2;
int64 value = 3;
}

View File

@ -4,6 +4,7 @@
package boltdb
import (
"errors"
"time"
"github.com/boltdb/bolt"
@ -11,8 +12,8 @@ import (
"storj.io/storj/storage"
)
// boltClient implements the KeyValueStore interface
type boltClient struct {
// Client is the entrypoint into a bolt data store
type Client struct {
logger *zap.Logger
db *bolt.DB
Path string
@ -37,13 +38,13 @@ var (
)
// NewClient instantiates a new BoltDB client given a zap logger, db file path, and a bucket name
func NewClient(logger *zap.Logger, path, bucket string) (storage.KeyValueStore, error) {
func NewClient(logger *zap.Logger, path, bucket string) (*Client, error) {
db, err := bolt.Open(path, fileMode, &bolt.Options{Timeout: defaultTimeout})
if err != nil {
return nil, err
}
return &boltClient{
return &Client{
logger: logger,
db: db,
Path: path,
@ -52,7 +53,7 @@ func NewClient(logger *zap.Logger, path, bucket string) (storage.KeyValueStore,
}
// Put adds a value to the provided key in boltdb, returning an error on failure.
func (c *boltClient) Put(key storage.Key, value storage.Value) error {
func (c *Client) Put(key storage.Key, value storage.Value) error {
c.logger.Debug("entering bolt put")
return c.db.Update(func(tx *bolt.Tx) error {
b, err := tx.CreateBucketIfNotExists(c.Bucket)
@ -65,7 +66,7 @@ func (c *boltClient) Put(key storage.Key, value storage.Value) error {
}
// Get looks up the provided key from boltdb returning either an error or the result.
func (c *boltClient) Get(pathKey storage.Key) (storage.Value, error) {
func (c *Client) Get(pathKey storage.Key) (storage.Value, error) {
c.logger.Debug("entering bolt get: " + string(pathKey))
var pointerBytes []byte
err := c.db.Update(func(tx *bolt.Tx) error {
@ -84,19 +85,19 @@ func (c *boltClient) Get(pathKey storage.Key) (storage.Value, error) {
}
// List returns either a list of keys for which boltdb has values or an error.
func (c *boltClient) List(startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
func (c *Client) List(startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
c.logger.Debug("entering bolt list")
return c.listHelper(false, startingKey, limit)
}
// ReverseList returns either a list of keys for which boltdb has values or an error.
// Starts from startingKey and iterates backwards
func (c *boltClient) ReverseList(startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
func (c *Client) ReverseList(startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
c.logger.Debug("entering bolt reverse list")
return c.listHelper(true, startingKey, limit)
}
func (c *boltClient) listHelper(reverseList bool, startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
func (c *Client) listHelper(reverseList bool, startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
var paths storage.Keys
err := c.db.Update(func(tx *bolt.Tx) error {
cur := tx.Bucket(c.Bucket).Cursor()
@ -134,7 +135,7 @@ func prevOrNext(reverseList bool, cur *bolt.Cursor) func() ([]byte, []byte) {
}
// Delete deletes a key/value pair from boltdb, for a given the key
func (c *boltClient) Delete(pathKey storage.Key) error {
func (c *Client) Delete(pathKey storage.Key) error {
c.logger.Debug("entering bolt delete: " + string(pathKey))
return c.db.Update(func(tx *bolt.Tx) error {
return tx.Bucket(c.Bucket).Delete(pathKey)
@ -142,6 +143,11 @@ func (c *boltClient) Delete(pathKey storage.Key) error {
}
// Close closes a BoltDB client
func (c *boltClient) Close() error {
func (c *Client) Close() error {
return c.db.Close()
}
// GetAll // TODO(coyle): implement
func (c *Client) GetAll(keys storage.Keys) (storage.Values, error) {
return nil, errors.New("Not Implemented")
}

View File

@ -37,7 +37,7 @@ func NewBoltClientTest(t *testing.T) *BoltClientTest {
func (bt *BoltClientTest) Close() {
bt.c.Close()
switch client := bt.c.(type) {
case *boltClient:
case *Client:
os.Remove(client.Path)
}
}

View File

@ -12,6 +12,9 @@ type Value []byte
// Keys is the type for a slice of keys in a `KeyValueStore`
type Keys []Key
// Values is the type for a slice of Values in a `KeyValueStore`
type Values []Value
// Limit indicates how many keys to return when calling List
type Limit int
@ -20,6 +23,7 @@ type KeyValueStore interface {
// Put adds a value to the provided key in the KeyValueStore, returning an error on failure.
Put(Key, Value) error
Get(Key) (Value, error)
GetAll(Keys) (Values, error)
List(Key, Limit) (Keys, error)
ReverseList(Key, Limit) (Keys, error)
Delete(Key) error

View File

@ -9,6 +9,7 @@ import (
"github.com/go-redis/redis"
"github.com/zeebo/errs"
"storj.io/storj/pkg/utils"
"storj.io/storj/storage"
)
@ -19,17 +20,18 @@ var (
const (
defaultNodeExpiration = 61 * time.Minute
maxKeyLookup = 100
)
// redisClient is the entrypoint into Redis
type redisClient struct {
// Client is the entrypoint into Redis
type Client struct {
db *redis.Client
TTL time.Duration
}
// NewClient returns a configured Client instance, verifying a sucessful connection to redis
func NewClient(address, password string, db int) (storage.KeyValueStore, error) {
c := &redisClient{
func NewClient(address, password string, db int) (*Client, error) {
c := &Client{
db: redis.NewClient(&redis.Options{
Addr: address,
Password: password,
@ -47,7 +49,7 @@ func NewClient(address, password string, db int) (storage.KeyValueStore, error)
}
// Get looks up the provided key from redis returning either an error or the result.
func (c *redisClient) Get(key storage.Key) (storage.Value, error) {
func (c *Client) Get(key storage.Key) (storage.Value, error) {
b, err := c.db.Get(string(key)).Bytes()
if err != nil {
if err.Error() == "redis: nil" {
@ -62,7 +64,7 @@ func (c *redisClient) Get(key storage.Key) (storage.Value, error) {
}
// Put adds a value to the provided key in redis, returning an error on failure.
func (c *redisClient) Put(key storage.Key, value storage.Value) error {
func (c *Client) Put(key storage.Key, value storage.Value) error {
v, err := value.MarshalBinary()
if err != nil {
@ -77,8 +79,8 @@ func (c *redisClient) Put(key storage.Key, value storage.Value) error {
return nil
}
// List returns either a list of keys for which redis has values or an error.
func (c *redisClient) List(startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
// List returns either a list of keys for which boltdb has values or an error.
func (c *Client) List(startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
var noOrderKeys []string
if startingKey != nil {
_, cursor, err := c.db.Scan(0, fmt.Sprintf("%s", startingKey), int64(limit)).Result()
@ -108,13 +110,13 @@ func (c *redisClient) List(startingKey storage.Key, limit storage.Limit) (storag
// ReverseList returns either a list of keys for which redis has values or an error.
// Starts from startingKey and iterates backwards
func (c *redisClient) ReverseList(startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
func (c *Client) ReverseList(startingKey storage.Key, limit storage.Limit) (storage.Keys, error) {
//TODO
return storage.Keys{}, nil
}
// Delete deletes a key/value pair from redis, for a given the key
func (c *redisClient) Delete(key storage.Key) error {
func (c *Client) Delete(key storage.Key) error {
err := c.db.Del(key.String()).Err()
if err != nil {
return Error.New("delete error", err)
@ -124,6 +126,37 @@ func (c *redisClient) Delete(key storage.Key) error {
}
// Close closes a redis client
func (c *redisClient) Close() error {
func (c *Client) Close() error {
return c.db.Close()
}
// GetAll is the bulk method for gets from the redis data store
// The maximum keys returned will be 100. If more than that is requested an
// error will be returned
func (c *Client) GetAll(keys storage.Keys) (storage.Values, error) {
lk := len(keys)
if lk > maxKeyLookup {
return nil, Error.New(fmt.Sprintf("requested %d keys, maximum is %d", lk, maxKeyLookup))
}
ks := make([]string, lk)
for i, v := range keys {
ks[i] = v.String()
}
vs, err := c.db.MGet(ks...).Result()
if err != nil {
return []storage.Value{}, err
}
values := []storage.Value{}
for _, v := range vs {
val, err := utils.GetBytes(v)
if err != nil {
}
values = append(values, storage.Value(val))
}
return values, nil
}

View File

@ -112,7 +112,7 @@ func testWithRedis(t *testing.T, testFunc TestFunc) {
}
func testWithInvalidConnection(t *testing.T, testFunc TestFunc) {
st := &redisClient{
st := &Client{
db: redis.NewClient(&redis.Options{
Addr: "",
Password: "",