diff --git a/pkg/eestream/mocks/mock_client.go b/pkg/eestream/mocks/mock_client.go deleted file mode 100644 index 82ba72382..000000000 --- a/pkg/eestream/mocks/mock_client.go +++ /dev/null @@ -1,119 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: storj.io/storj/pkg/eestream (interfaces: ErasureScheme) - -// Package mock_eestream is a generated GoMock package. -package mock_eestream - -import ( - reflect "reflect" - - gomock "github.com/golang/mock/gomock" -) - -// MockErasureScheme is a mock of ErasureScheme interface -type MockErasureScheme struct { - ctrl *gomock.Controller - recorder *MockErasureSchemeMockRecorder -} - -// MockErasureSchemeMockRecorder is the mock recorder for MockErasureScheme -type MockErasureSchemeMockRecorder struct { - mock *MockErasureScheme -} - -// NewMockErasureScheme creates a new mock instance -func NewMockErasureScheme(ctrl *gomock.Controller) *MockErasureScheme { - mock := &MockErasureScheme{ctrl: ctrl} - mock.recorder = &MockErasureSchemeMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockErasureScheme) EXPECT() *MockErasureSchemeMockRecorder { - return m.recorder -} - -// Decode mocks base method -func (m *MockErasureScheme) Decode(arg0 []byte, arg1 map[int][]byte) ([]byte, error) { - ret := m.ctrl.Call(m, "Decode", arg0, arg1) - ret0, _ := ret[0].([]byte) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Decode indicates an expected call of Decode -func (mr *MockErasureSchemeMockRecorder) Decode(arg0, arg1 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Decode", reflect.TypeOf((*MockErasureScheme)(nil).Decode), arg0, arg1) -} - -// Encode mocks base method -func (m *MockErasureScheme) Encode(arg0 []byte, arg1 func(int, []byte)) error { - ret := m.ctrl.Call(m, "Encode", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// Encode indicates an expected call of Encode -func (mr *MockErasureSchemeMockRecorder) Encode(arg0, arg1 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Encode", reflect.TypeOf((*MockErasureScheme)(nil).Encode), arg0, arg1) -} - -// EncodeSingle mocks base method -func (m *MockErasureScheme) EncodeSingle(arg0, arg1 []byte, arg2 int) error { - ret := m.ctrl.Call(m, "EncodeSingle", arg0, arg1, arg2) - ret0, _ := ret[0].(error) - return ret0 -} - -// EncodeSingle indicates an expected call of EncodeSingle -func (mr *MockErasureSchemeMockRecorder) EncodeSingle(arg0, arg1, arg2 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EncodeSingle", reflect.TypeOf((*MockErasureScheme)(nil).EncodeSingle), arg0, arg1, arg2) -} - -// ErasureShareSize mocks base method -func (m *MockErasureScheme) ErasureShareSize() int { - ret := m.ctrl.Call(m, "ErasureShareSize") - ret0, _ := ret[0].(int) - return ret0 -} - -// ErasureShareSize indicates an expected call of ErasureShareSize -func (mr *MockErasureSchemeMockRecorder) ErasureShareSize() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ErasureShareSize", reflect.TypeOf((*MockErasureScheme)(nil).ErasureShareSize)) -} - -// RequiredCount mocks base method -func (m *MockErasureScheme) RequiredCount() int { - ret := m.ctrl.Call(m, "RequiredCount") - ret0, _ := ret[0].(int) - return ret0 -} - -// RequiredCount indicates an expected call of RequiredCount -func (mr *MockErasureSchemeMockRecorder) RequiredCount() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RequiredCount", reflect.TypeOf((*MockErasureScheme)(nil).RequiredCount)) -} - -// StripeSize mocks base method -func (m *MockErasureScheme) StripeSize() int { - ret := m.ctrl.Call(m, "StripeSize") - ret0, _ := ret[0].(int) - return ret0 -} - -// StripeSize indicates an expected call of StripeSize -func (mr *MockErasureSchemeMockRecorder) StripeSize() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StripeSize", reflect.TypeOf((*MockErasureScheme)(nil).StripeSize)) -} - -// TotalCount mocks base method -func (m *MockErasureScheme) TotalCount() int { - ret := m.ctrl.Call(m, "TotalCount") - ret0, _ := ret[0].(int) - return ret0 -} - -// TotalCount indicates an expected call of TotalCount -func (mr *MockErasureSchemeMockRecorder) TotalCount() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TotalCount", reflect.TypeOf((*MockErasureScheme)(nil).TotalCount)) -} diff --git a/pkg/pb/piecestore.pb.go b/pkg/pb/piecestore.pb.go index 9451b87db..e4e03548b 100644 --- a/pkg/pb/piecestore.pb.go +++ b/pkg/pb/piecestore.pb.go @@ -4,12 +4,10 @@ package pb import ( - context "context" fmt "fmt" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" _ "github.com/golang/protobuf/ptypes/duration" - grpc "google.golang.org/grpc" math "math" ) @@ -209,524 +207,6 @@ func (m *RenterBandwidthAllocation) GetSignature() []byte { return nil } -type PieceStore struct { - BandwidthAllocation *RenterBandwidthAllocation `protobuf:"bytes,1,opt,name=bandwidth_allocation,json=bandwidthAllocation,proto3" json:"bandwidth_allocation,omitempty"` - PieceData *PieceStore_PieceData `protobuf:"bytes,2,opt,name=piece_data,json=pieceData,proto3" json:"piece_data,omitempty"` - Authorization *SignedMessage `protobuf:"bytes,3,opt,name=authorization,proto3" json:"authorization,omitempty"` // Deprecated: Do not use. - SignedHash *SignedHash `protobuf:"bytes,4,opt,name=signed_hash,json=signedHash,proto3" json:"signed_hash,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceStore) Reset() { *m = PieceStore{} } -func (m *PieceStore) String() string { return proto.CompactTextString(m) } -func (*PieceStore) ProtoMessage() {} -func (*PieceStore) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{2} -} -func (m *PieceStore) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceStore.Unmarshal(m, b) -} -func (m *PieceStore) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceStore.Marshal(b, m, deterministic) -} -func (m *PieceStore) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceStore.Merge(m, src) -} -func (m *PieceStore) XXX_Size() int { - return xxx_messageInfo_PieceStore.Size(m) -} -func (m *PieceStore) XXX_DiscardUnknown() { - xxx_messageInfo_PieceStore.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceStore proto.InternalMessageInfo - -func (m *PieceStore) GetBandwidthAllocation() *RenterBandwidthAllocation { - if m != nil { - return m.BandwidthAllocation - } - return nil -} - -func (m *PieceStore) GetPieceData() *PieceStore_PieceData { - if m != nil { - return m.PieceData - } - return nil -} - -// Deprecated: Do not use. -func (m *PieceStore) GetAuthorization() *SignedMessage { - if m != nil { - return m.Authorization - } - return nil -} - -func (m *PieceStore) GetSignedHash() *SignedHash { - if m != nil { - return m.SignedHash - } - return nil -} - -type PieceStore_PieceData struct { - // TODO: may want to use customtype and fixed-length byte slice - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - ExpirationUnixSec int64 `protobuf:"varint,2,opt,name=expiration_unix_sec,json=expirationUnixSec,proto3" json:"expiration_unix_sec,omitempty"` - Content []byte `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceStore_PieceData) Reset() { *m = PieceStore_PieceData{} } -func (m *PieceStore_PieceData) String() string { return proto.CompactTextString(m) } -func (*PieceStore_PieceData) ProtoMessage() {} -func (*PieceStore_PieceData) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{2, 0} -} -func (m *PieceStore_PieceData) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceStore_PieceData.Unmarshal(m, b) -} -func (m *PieceStore_PieceData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceStore_PieceData.Marshal(b, m, deterministic) -} -func (m *PieceStore_PieceData) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceStore_PieceData.Merge(m, src) -} -func (m *PieceStore_PieceData) XXX_Size() int { - return xxx_messageInfo_PieceStore_PieceData.Size(m) -} -func (m *PieceStore_PieceData) XXX_DiscardUnknown() { - xxx_messageInfo_PieceStore_PieceData.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceStore_PieceData proto.InternalMessageInfo - -func (m *PieceStore_PieceData) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *PieceStore_PieceData) GetExpirationUnixSec() int64 { - if m != nil { - return m.ExpirationUnixSec - } - return 0 -} - -func (m *PieceStore_PieceData) GetContent() []byte { - if m != nil { - return m.Content - } - return nil -} - -type PieceId struct { - // TODO: may want to use customtype and fixed-length byte slice - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Authorization *SignedMessage `protobuf:"bytes,2,opt,name=authorization,proto3" json:"authorization,omitempty"` // Deprecated: Do not use. - SatelliteId NodeID `protobuf:"bytes,3,opt,name=satellite_id,json=satelliteId,proto3,customtype=NodeID" json:"satellite_id"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceId) Reset() { *m = PieceId{} } -func (m *PieceId) String() string { return proto.CompactTextString(m) } -func (*PieceId) ProtoMessage() {} -func (*PieceId) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{3} -} -func (m *PieceId) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceId.Unmarshal(m, b) -} -func (m *PieceId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceId.Marshal(b, m, deterministic) -} -func (m *PieceId) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceId.Merge(m, src) -} -func (m *PieceId) XXX_Size() int { - return xxx_messageInfo_PieceId.Size(m) -} -func (m *PieceId) XXX_DiscardUnknown() { - xxx_messageInfo_PieceId.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceId proto.InternalMessageInfo - -func (m *PieceId) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -// Deprecated: Do not use. -func (m *PieceId) GetAuthorization() *SignedMessage { - if m != nil { - return m.Authorization - } - return nil -} - -type PieceSummary struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - PieceSize int64 `protobuf:"varint,2,opt,name=piece_size,json=pieceSize,proto3" json:"piece_size,omitempty"` - ExpirationUnixSec int64 `protobuf:"varint,3,opt,name=expiration_unix_sec,json=expirationUnixSec,proto3" json:"expiration_unix_sec,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceSummary) Reset() { *m = PieceSummary{} } -func (m *PieceSummary) String() string { return proto.CompactTextString(m) } -func (*PieceSummary) ProtoMessage() {} -func (*PieceSummary) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{4} -} -func (m *PieceSummary) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceSummary.Unmarshal(m, b) -} -func (m *PieceSummary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceSummary.Marshal(b, m, deterministic) -} -func (m *PieceSummary) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceSummary.Merge(m, src) -} -func (m *PieceSummary) XXX_Size() int { - return xxx_messageInfo_PieceSummary.Size(m) -} -func (m *PieceSummary) XXX_DiscardUnknown() { - xxx_messageInfo_PieceSummary.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceSummary proto.InternalMessageInfo - -func (m *PieceSummary) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *PieceSummary) GetPieceSize() int64 { - if m != nil { - return m.PieceSize - } - return 0 -} - -func (m *PieceSummary) GetExpirationUnixSec() int64 { - if m != nil { - return m.ExpirationUnixSec - } - return 0 -} - -type PieceRetrieval struct { - BandwidthAllocation *RenterBandwidthAllocation `protobuf:"bytes,1,opt,name=bandwidth_allocation,json=bandwidthAllocation,proto3" json:"bandwidth_allocation,omitempty"` - PieceData *PieceRetrieval_PieceData `protobuf:"bytes,2,opt,name=piece_data,json=pieceData,proto3" json:"piece_data,omitempty"` - Authorization *SignedMessage `protobuf:"bytes,3,opt,name=authorization,proto3" json:"authorization,omitempty"` // Deprecated: Do not use. - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceRetrieval) Reset() { *m = PieceRetrieval{} } -func (m *PieceRetrieval) String() string { return proto.CompactTextString(m) } -func (*PieceRetrieval) ProtoMessage() {} -func (*PieceRetrieval) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{5} -} -func (m *PieceRetrieval) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceRetrieval.Unmarshal(m, b) -} -func (m *PieceRetrieval) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceRetrieval.Marshal(b, m, deterministic) -} -func (m *PieceRetrieval) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceRetrieval.Merge(m, src) -} -func (m *PieceRetrieval) XXX_Size() int { - return xxx_messageInfo_PieceRetrieval.Size(m) -} -func (m *PieceRetrieval) XXX_DiscardUnknown() { - xxx_messageInfo_PieceRetrieval.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceRetrieval proto.InternalMessageInfo - -func (m *PieceRetrieval) GetBandwidthAllocation() *RenterBandwidthAllocation { - if m != nil { - return m.BandwidthAllocation - } - return nil -} - -func (m *PieceRetrieval) GetPieceData() *PieceRetrieval_PieceData { - if m != nil { - return m.PieceData - } - return nil -} - -// Deprecated: Do not use. -func (m *PieceRetrieval) GetAuthorization() *SignedMessage { - if m != nil { - return m.Authorization - } - return nil -} - -type PieceRetrieval_PieceData struct { - // TODO: may want to use customtype and fixed-length byte slice - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - PieceSize int64 `protobuf:"varint,2,opt,name=piece_size,json=pieceSize,proto3" json:"piece_size,omitempty"` - Offset int64 `protobuf:"varint,3,opt,name=offset,proto3" json:"offset,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceRetrieval_PieceData) Reset() { *m = PieceRetrieval_PieceData{} } -func (m *PieceRetrieval_PieceData) String() string { return proto.CompactTextString(m) } -func (*PieceRetrieval_PieceData) ProtoMessage() {} -func (*PieceRetrieval_PieceData) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{5, 0} -} -func (m *PieceRetrieval_PieceData) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceRetrieval_PieceData.Unmarshal(m, b) -} -func (m *PieceRetrieval_PieceData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceRetrieval_PieceData.Marshal(b, m, deterministic) -} -func (m *PieceRetrieval_PieceData) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceRetrieval_PieceData.Merge(m, src) -} -func (m *PieceRetrieval_PieceData) XXX_Size() int { - return xxx_messageInfo_PieceRetrieval_PieceData.Size(m) -} -func (m *PieceRetrieval_PieceData) XXX_DiscardUnknown() { - xxx_messageInfo_PieceRetrieval_PieceData.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceRetrieval_PieceData proto.InternalMessageInfo - -func (m *PieceRetrieval_PieceData) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *PieceRetrieval_PieceData) GetPieceSize() int64 { - if m != nil { - return m.PieceSize - } - return 0 -} - -func (m *PieceRetrieval_PieceData) GetOffset() int64 { - if m != nil { - return m.Offset - } - return 0 -} - -type PieceRetrievalStream struct { - PieceSize int64 `protobuf:"varint,1,opt,name=piece_size,json=pieceSize,proto3" json:"piece_size,omitempty"` - Content []byte `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceRetrievalStream) Reset() { *m = PieceRetrievalStream{} } -func (m *PieceRetrievalStream) String() string { return proto.CompactTextString(m) } -func (*PieceRetrievalStream) ProtoMessage() {} -func (*PieceRetrievalStream) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{6} -} -func (m *PieceRetrievalStream) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceRetrievalStream.Unmarshal(m, b) -} -func (m *PieceRetrievalStream) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceRetrievalStream.Marshal(b, m, deterministic) -} -func (m *PieceRetrievalStream) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceRetrievalStream.Merge(m, src) -} -func (m *PieceRetrievalStream) XXX_Size() int { - return xxx_messageInfo_PieceRetrievalStream.Size(m) -} -func (m *PieceRetrievalStream) XXX_DiscardUnknown() { - xxx_messageInfo_PieceRetrievalStream.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceRetrievalStream proto.InternalMessageInfo - -func (m *PieceRetrievalStream) GetPieceSize() int64 { - if m != nil { - return m.PieceSize - } - return 0 -} - -func (m *PieceRetrievalStream) GetContent() []byte { - if m != nil { - return m.Content - } - return nil -} - -type PieceDelete struct { - // TODO: may want to use customtype and fixed-length byte slice - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Authorization *SignedMessage `protobuf:"bytes,3,opt,name=authorization,proto3" json:"authorization,omitempty"` // Deprecated: Do not use. - SatelliteId NodeID `protobuf:"bytes,4,opt,name=satellite_id,json=satelliteId,proto3,customtype=NodeID" json:"satellite_id"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceDelete) Reset() { *m = PieceDelete{} } -func (m *PieceDelete) String() string { return proto.CompactTextString(m) } -func (*PieceDelete) ProtoMessage() {} -func (*PieceDelete) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{7} -} -func (m *PieceDelete) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceDelete.Unmarshal(m, b) -} -func (m *PieceDelete) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceDelete.Marshal(b, m, deterministic) -} -func (m *PieceDelete) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceDelete.Merge(m, src) -} -func (m *PieceDelete) XXX_Size() int { - return xxx_messageInfo_PieceDelete.Size(m) -} -func (m *PieceDelete) XXX_DiscardUnknown() { - xxx_messageInfo_PieceDelete.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceDelete proto.InternalMessageInfo - -func (m *PieceDelete) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -// Deprecated: Do not use. -func (m *PieceDelete) GetAuthorization() *SignedMessage { - if m != nil { - return m.Authorization - } - return nil -} - -type PieceDeleteSummary struct { - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceDeleteSummary) Reset() { *m = PieceDeleteSummary{} } -func (m *PieceDeleteSummary) String() string { return proto.CompactTextString(m) } -func (*PieceDeleteSummary) ProtoMessage() {} -func (*PieceDeleteSummary) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{8} -} -func (m *PieceDeleteSummary) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceDeleteSummary.Unmarshal(m, b) -} -func (m *PieceDeleteSummary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceDeleteSummary.Marshal(b, m, deterministic) -} -func (m *PieceDeleteSummary) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceDeleteSummary.Merge(m, src) -} -func (m *PieceDeleteSummary) XXX_Size() int { - return xxx_messageInfo_PieceDeleteSummary.Size(m) -} -func (m *PieceDeleteSummary) XXX_DiscardUnknown() { - xxx_messageInfo_PieceDeleteSummary.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceDeleteSummary proto.InternalMessageInfo - -func (m *PieceDeleteSummary) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -type PieceStoreSummary struct { - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - TotalReceived int64 `protobuf:"varint,2,opt,name=total_received,json=totalReceived,proto3" json:"total_received,omitempty"` - SignedHash *SignedHash `protobuf:"bytes,3,opt,name=signed_hash,json=signedHash,proto3" json:"signed_hash,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PieceStoreSummary) Reset() { *m = PieceStoreSummary{} } -func (m *PieceStoreSummary) String() string { return proto.CompactTextString(m) } -func (*PieceStoreSummary) ProtoMessage() {} -func (*PieceStoreSummary) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{9} -} -func (m *PieceStoreSummary) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PieceStoreSummary.Unmarshal(m, b) -} -func (m *PieceStoreSummary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PieceStoreSummary.Marshal(b, m, deterministic) -} -func (m *PieceStoreSummary) XXX_Merge(src proto.Message) { - xxx_messageInfo_PieceStoreSummary.Merge(m, src) -} -func (m *PieceStoreSummary) XXX_Size() int { - return xxx_messageInfo_PieceStoreSummary.Size(m) -} -func (m *PieceStoreSummary) XXX_DiscardUnknown() { - xxx_messageInfo_PieceStoreSummary.DiscardUnknown(m) -} - -var xxx_messageInfo_PieceStoreSummary proto.InternalMessageInfo - -func (m *PieceStoreSummary) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func (m *PieceStoreSummary) GetTotalReceived() int64 { - if m != nil { - return m.TotalReceived - } - return 0 -} - -func (m *PieceStoreSummary) GetSignedHash() *SignedHash { - if m != nil { - return m.SignedHash - } - return nil -} - type SignedMessage struct { Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` @@ -740,7 +220,7 @@ func (m *SignedMessage) Reset() { *m = SignedMessage{} } func (m *SignedMessage) String() string { return proto.CompactTextString(m) } func (*SignedMessage) ProtoMessage() {} func (*SignedMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{10} + return fileDescriptor_569d535d76469daf, []int{2} } func (m *SignedMessage) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignedMessage.Unmarshal(m, b) @@ -794,7 +274,7 @@ func (m *SignedHash) Reset() { *m = SignedHash{} } func (m *SignedHash) String() string { return proto.CompactTextString(m) } func (*SignedHash) ProtoMessage() {} func (*SignedHash) Descriptor() ([]byte, []int) { - return fileDescriptor_569d535d76469daf, []int{11} + return fileDescriptor_569d535d76469daf, []int{3} } func (m *SignedHash) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SignedHash.Unmarshal(m, b) @@ -839,16 +319,6 @@ func init() { proto.RegisterEnum("piecestoreroutes.BandwidthAction", BandwidthAction_name, BandwidthAction_value) proto.RegisterType((*PayerBandwidthAllocation)(nil), "piecestoreroutes.PayerBandwidthAllocation") proto.RegisterType((*RenterBandwidthAllocation)(nil), "piecestoreroutes.RenterBandwidthAllocation") - proto.RegisterType((*PieceStore)(nil), "piecestoreroutes.PieceStore") - proto.RegisterType((*PieceStore_PieceData)(nil), "piecestoreroutes.PieceStore.PieceData") - proto.RegisterType((*PieceId)(nil), "piecestoreroutes.PieceId") - proto.RegisterType((*PieceSummary)(nil), "piecestoreroutes.PieceSummary") - proto.RegisterType((*PieceRetrieval)(nil), "piecestoreroutes.PieceRetrieval") - proto.RegisterType((*PieceRetrieval_PieceData)(nil), "piecestoreroutes.PieceRetrieval.PieceData") - proto.RegisterType((*PieceRetrievalStream)(nil), "piecestoreroutes.PieceRetrievalStream") - proto.RegisterType((*PieceDelete)(nil), "piecestoreroutes.PieceDelete") - proto.RegisterType((*PieceDeleteSummary)(nil), "piecestoreroutes.PieceDeleteSummary") - proto.RegisterType((*PieceStoreSummary)(nil), "piecestoreroutes.PieceStoreSummary") proto.RegisterType((*SignedMessage)(nil), "piecestoreroutes.SignedMessage") proto.RegisterType((*SignedHash)(nil), "piecestoreroutes.SignedHash") } @@ -856,304 +326,40 @@ func init() { func init() { proto.RegisterFile("piecestore.proto", fileDescriptor_569d535d76469daf) } var fileDescriptor_569d535d76469daf = []byte{ - // 968 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcd, 0x6e, 0xdb, 0xc6, - 0x13, 0x37, 0x49, 0x7d, 0x58, 0x23, 0x4b, 0x56, 0x36, 0xc6, 0x1f, 0xb4, 0xe0, 0xc4, 0xfa, 0x33, - 0x6d, 0x20, 0x38, 0x80, 0xd3, 0xaa, 0x40, 0x81, 0x1e, 0x7a, 0xb0, 0x60, 0x23, 0x15, 0x8a, 0x3a, - 0xc2, 0x4a, 0xbe, 0xa4, 0x40, 0xd9, 0x15, 0x39, 0x96, 0x16, 0xa1, 0x48, 0x81, 0x5c, 0xa6, 0xb2, - 0xaf, 0x7d, 0x84, 0x1e, 0x7a, 0xe8, 0xb5, 0x0f, 0xd3, 0x17, 0xe8, 0x25, 0x87, 0x3c, 0x48, 0x4f, - 0x05, 0x77, 0x29, 0xc9, 0xfa, 0xa0, 0x84, 0x16, 0xcd, 0x6d, 0x67, 0x76, 0x38, 0xfb, 0x9b, 0xf9, - 0xcd, 0x07, 0xa1, 0x36, 0xe1, 0xe8, 0x60, 0x24, 0x82, 0x10, 0xcf, 0x27, 0x61, 0x20, 0x02, 0xf2, - 0x40, 0x13, 0x06, 0xb1, 0xc0, 0xa8, 0x0e, 0xc3, 0x60, 0x18, 0xa8, 0xdb, 0xfa, 0xd3, 0x61, 0x10, - 0x0c, 0x3d, 0x7c, 0x29, 0xa5, 0x41, 0x7c, 0xfb, 0xd2, 0x8d, 0x43, 0x26, 0x78, 0xe0, 0xab, 0x7b, - 0xeb, 0x67, 0x03, 0xcc, 0x2e, 0xbb, 0xc3, 0xb0, 0xcd, 0x7c, 0xf7, 0x27, 0xee, 0x8a, 0xd1, 0x85, - 0xe7, 0x05, 0x8e, 0x34, 0x21, 0x9f, 0xc3, 0x41, 0xc4, 0x04, 0x7a, 0x1e, 0x17, 0x68, 0x73, 0xd7, - 0xd4, 0x1a, 0x5a, 0xf3, 0xa0, 0x5d, 0xfd, 0xe3, 0xc3, 0xe9, 0xde, 0xfb, 0x0f, 0xa7, 0x85, 0xeb, - 0xc0, 0xc5, 0xce, 0x25, 0x2d, 0xcf, 0x6d, 0x3a, 0x2e, 0x79, 0x01, 0xa5, 0x78, 0xe2, 0x71, 0xff, - 0x6d, 0x62, 0xaf, 0x6f, 0xb4, 0xdf, 0x57, 0x06, 0x1d, 0x97, 0x1c, 0xc3, 0xfe, 0x98, 0x4d, 0xed, - 0x88, 0xdf, 0xa3, 0x69, 0x34, 0xb4, 0xa6, 0x41, 0x8b, 0x63, 0x36, 0xed, 0xf1, 0x7b, 0x24, 0xe7, - 0xf0, 0x18, 0xa7, 0x13, 0xae, 0xb0, 0xda, 0xb1, 0xcf, 0xa7, 0x76, 0x84, 0x8e, 0x99, 0x93, 0x56, - 0x8f, 0x16, 0x57, 0x37, 0x3e, 0x9f, 0xf6, 0xd0, 0x21, 0xcf, 0xa0, 0x12, 0x61, 0xc8, 0x99, 0x67, - 0xfb, 0xf1, 0x78, 0x80, 0xa1, 0x99, 0x6f, 0x68, 0xcd, 0x12, 0x3d, 0x50, 0xca, 0x6b, 0xa9, 0x23, - 0x5f, 0x41, 0x81, 0x39, 0xc9, 0x57, 0x66, 0xa1, 0xa1, 0x35, 0xab, 0xad, 0xff, 0x9f, 0xaf, 0xe6, - 0xee, 0x7c, 0x91, 0x06, 0x69, 0x48, 0xd3, 0x0f, 0x48, 0x13, 0x6a, 0x4e, 0x88, 0x4c, 0xa0, 0xbb, - 0x00, 0x53, 0x94, 0x60, 0xaa, 0xa9, 0x7e, 0x86, 0xe4, 0x08, 0xf2, 0x0e, 0x86, 0x22, 0x32, 0xf7, - 0x1b, 0x46, 0xf3, 0x80, 0x2a, 0x81, 0x9c, 0x40, 0x29, 0xe2, 0x43, 0x9f, 0x89, 0x38, 0x44, 0xb3, - 0x94, 0xe4, 0x85, 0x2e, 0x14, 0xd6, 0x5f, 0x1a, 0x1c, 0x53, 0xf4, 0xc5, 0x66, 0x1a, 0xbe, 0x87, - 0xda, 0x24, 0xa1, 0xc8, 0x66, 0x73, 0x9d, 0xa4, 0xa2, 0xdc, 0x3a, 0x5b, 0x0f, 0x20, 0x8b, 0xcc, - 0x76, 0x2e, 0xa1, 0x81, 0x1e, 0x4a, 0x4f, 0x0f, 0x9c, 0x1f, 0x41, 0x5e, 0x04, 0x82, 0x79, 0x92, - 0x2c, 0x83, 0x2a, 0x81, 0x7c, 0x09, 0x87, 0x89, 0x53, 0x36, 0x44, 0xdb, 0x0f, 0x5c, 0x49, 0xbe, - 0xb1, 0x91, 0xcc, 0x4a, 0x6a, 0x26, 0x45, 0x77, 0x11, 0x7c, 0x2e, 0x33, 0xf8, 0xfc, 0x6a, 0xf0, - 0xbf, 0x1b, 0x00, 0xdd, 0x24, 0x8c, 0x5e, 0x12, 0x06, 0xf9, 0x01, 0x8e, 0x06, 0x33, 0xf8, 0xeb, - 0x11, 0xbf, 0x58, 0x8f, 0x38, 0x33, 0x71, 0xf4, 0xf1, 0x60, 0x43, 0x36, 0xaf, 0x00, 0xa4, 0x0b, - 0xdb, 0x65, 0x82, 0xc9, 0xa8, 0xcb, 0xad, 0xe7, 0x1b, 0xf2, 0x38, 0x47, 0xa4, 0x8e, 0x97, 0x4c, - 0x30, 0x5a, 0x9a, 0xcc, 0x8e, 0xa4, 0x03, 0x15, 0x16, 0x8b, 0x51, 0x10, 0xf2, 0x7b, 0x85, 0xcf, - 0x90, 0x9e, 0x4e, 0xd7, 0x3d, 0xf5, 0xf8, 0xd0, 0x47, 0xf7, 0x3b, 0x8c, 0x22, 0x36, 0xc4, 0xb6, - 0x6e, 0x6a, 0x74, 0xf9, 0x4b, 0xf2, 0x35, 0x94, 0x23, 0x69, 0x63, 0x8f, 0x58, 0x34, 0x92, 0x35, - 0x5e, 0x6e, 0x9d, 0x64, 0x39, 0xfa, 0x86, 0x45, 0x23, 0x0a, 0xd1, 0xfc, 0x5c, 0x47, 0x28, 0xcd, - 0x11, 0x92, 0x2a, 0xe8, 0x69, 0xa3, 0x96, 0xa8, 0xce, 0xdd, 0xac, 0x3e, 0xd2, 0xb3, 0xfa, 0xc8, - 0x84, 0xa2, 0x13, 0xf8, 0x02, 0x7d, 0xa1, 0x08, 0xa7, 0x33, 0xd1, 0xfa, 0x55, 0x83, 0xa2, 0x7c, - 0xa7, 0xe3, 0xae, 0xbd, 0xb2, 0x96, 0x0c, 0xfd, 0x5f, 0x27, 0x63, 0x75, 0xe6, 0x18, 0x3b, 0x67, - 0x8e, 0x35, 0x86, 0x03, 0xc5, 0x56, 0x3c, 0x1e, 0xb3, 0xf0, 0x6e, 0x0d, 0xdd, 0x93, 0x19, 0xe3, - 0x72, 0xd0, 0xa8, 0xd0, 0x15, 0x93, 0xdb, 0x46, 0x8d, 0x91, 0x91, 0x22, 0xeb, 0xbd, 0x0e, 0x55, - 0xf9, 0x1e, 0x45, 0x11, 0x72, 0x7c, 0xc7, 0xbc, 0x8f, 0x5e, 0xb3, 0x9d, 0x0d, 0x35, 0x7b, 0x96, - 0x51, 0xb3, 0x73, 0x54, 0x1f, 0xbb, 0x6e, 0xeb, 0x74, 0x5b, 0xe1, 0xed, 0x48, 0xfa, 0xff, 0xa0, - 0x10, 0xdc, 0xde, 0x46, 0x28, 0xd2, 0x3c, 0xa7, 0x92, 0xf5, 0x1a, 0x8e, 0x96, 0xa3, 0xe8, 0x89, - 0x10, 0xd9, 0x78, 0xc5, 0x9d, 0xb6, 0xea, 0xee, 0x41, 0xd9, 0xea, 0xcb, 0x65, 0xfb, 0x9b, 0x06, - 0x65, 0x85, 0x12, 0x3d, 0x14, 0xb8, 0xbb, 0x74, 0x8d, 0xff, 0xac, 0x74, 0x73, 0xbb, 0x4b, 0xf7, - 0x1c, 0xc8, 0x03, 0x70, 0xb3, 0x02, 0x36, 0xa1, 0x38, 0x56, 0xcf, 0xa4, 0x40, 0x67, 0xa2, 0xf5, - 0x8b, 0x06, 0x8f, 0x16, 0x93, 0x69, 0xa7, 0x3d, 0xf9, 0x14, 0xaa, 0x72, 0xa0, 0xdb, 0x21, 0x3a, - 0xc8, 0xdf, 0xa1, 0x9b, 0x32, 0x51, 0x91, 0x5a, 0x9a, 0x2a, 0x57, 0x27, 0x90, 0xf1, 0xcf, 0x26, - 0x90, 0xf5, 0x23, 0x54, 0x96, 0x92, 0x43, 0x08, 0xe4, 0x64, 0xa5, 0xca, 0x1f, 0x06, 0x2a, 0xcf, - 0xcb, 0x4b, 0x40, 0x5f, 0x59, 0x02, 0x92, 0xdf, 0x78, 0xe0, 0x71, 0xc7, 0x7e, 0x8b, 0x77, 0xe9, - 0xe8, 0x29, 0x29, 0xcd, 0xb7, 0x78, 0x67, 0xf5, 0x01, 0x16, 0x6f, 0x27, 0xee, 0x25, 0xce, 0xd4, - 0x7d, 0x72, 0x5e, 0x6c, 0x1e, 0x3d, 0x73, 0xf3, 0x18, 0x2b, 0x8f, 0x9e, 0x51, 0x38, 0x5c, 0xd9, - 0xf7, 0xa4, 0x08, 0x46, 0xf7, 0xa6, 0x5f, 0xdb, 0x4b, 0x0e, 0xaf, 0xae, 0xfa, 0x35, 0x8d, 0x54, - 0xa0, 0xf4, 0xea, 0xaa, 0x6f, 0x5f, 0xdc, 0x5c, 0x76, 0xfa, 0x35, 0x9d, 0x54, 0x01, 0x12, 0x91, - 0x5e, 0x75, 0x2f, 0x3a, 0xb4, 0x66, 0x24, 0x72, 0xf7, 0x66, 0x2e, 0xe7, 0x5a, 0x7f, 0xea, 0x50, - 0x5b, 0x30, 0x44, 0x65, 0xde, 0xc8, 0x25, 0xe4, 0xa5, 0x8e, 0x1c, 0x67, 0x34, 0x6d, 0xc7, 0xad, - 0x3f, 0xcd, 0xda, 0x41, 0x8a, 0x64, 0x6b, 0x8f, 0xbc, 0x81, 0xfd, 0xb4, 0x2d, 0x90, 0x34, 0x76, - 0x75, 0x7f, 0xfd, 0xf9, 0x2e, 0x0b, 0xd5, 0x59, 0xd6, 0x5e, 0x53, 0xfb, 0x4c, 0x23, 0xd7, 0x90, - 0x57, 0xeb, 0xf7, 0x64, 0xdb, 0x2a, 0xac, 0x3f, 0xdb, 0x76, 0x3b, 0x47, 0xda, 0xd4, 0xc8, 0x6b, - 0x28, 0xa4, 0x0d, 0xf7, 0x24, 0xe3, 0x13, 0x75, 0x5d, 0xff, 0x64, 0xeb, 0xf5, 0xdc, 0x65, 0x3b, - 0xf7, 0x46, 0x9f, 0x0c, 0x06, 0x05, 0xf9, 0xd7, 0xfa, 0xc5, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, - 0xba, 0xef, 0xb1, 0x53, 0x07, 0x0b, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// PieceStoreRoutesClient is the client API for PieceStoreRoutes service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type PieceStoreRoutesClient interface { - Piece(ctx context.Context, in *PieceId, opts ...grpc.CallOption) (*PieceSummary, error) - Retrieve(ctx context.Context, opts ...grpc.CallOption) (PieceStoreRoutes_RetrieveClient, error) - Store(ctx context.Context, opts ...grpc.CallOption) (PieceStoreRoutes_StoreClient, error) - Delete(ctx context.Context, in *PieceDelete, opts ...grpc.CallOption) (*PieceDeleteSummary, error) -} - -type pieceStoreRoutesClient struct { - cc *grpc.ClientConn -} - -func NewPieceStoreRoutesClient(cc *grpc.ClientConn) PieceStoreRoutesClient { - return &pieceStoreRoutesClient{cc} -} - -func (c *pieceStoreRoutesClient) Piece(ctx context.Context, in *PieceId, opts ...grpc.CallOption) (*PieceSummary, error) { - out := new(PieceSummary) - err := c.cc.Invoke(ctx, "/piecestoreroutes.PieceStoreRoutes/Piece", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *pieceStoreRoutesClient) Retrieve(ctx context.Context, opts ...grpc.CallOption) (PieceStoreRoutes_RetrieveClient, error) { - stream, err := c.cc.NewStream(ctx, &_PieceStoreRoutes_serviceDesc.Streams[0], "/piecestoreroutes.PieceStoreRoutes/Retrieve", opts...) - if err != nil { - return nil, err - } - x := &pieceStoreRoutesRetrieveClient{stream} - return x, nil -} - -type PieceStoreRoutes_RetrieveClient interface { - Send(*PieceRetrieval) error - Recv() (*PieceRetrievalStream, error) - grpc.ClientStream -} - -type pieceStoreRoutesRetrieveClient struct { - grpc.ClientStream -} - -func (x *pieceStoreRoutesRetrieveClient) Send(m *PieceRetrieval) error { - return x.ClientStream.SendMsg(m) -} - -func (x *pieceStoreRoutesRetrieveClient) Recv() (*PieceRetrievalStream, error) { - m := new(PieceRetrievalStream) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *pieceStoreRoutesClient) Store(ctx context.Context, opts ...grpc.CallOption) (PieceStoreRoutes_StoreClient, error) { - stream, err := c.cc.NewStream(ctx, &_PieceStoreRoutes_serviceDesc.Streams[1], "/piecestoreroutes.PieceStoreRoutes/Store", opts...) - if err != nil { - return nil, err - } - x := &pieceStoreRoutesStoreClient{stream} - return x, nil -} - -type PieceStoreRoutes_StoreClient interface { - Send(*PieceStore) error - CloseAndRecv() (*PieceStoreSummary, error) - grpc.ClientStream -} - -type pieceStoreRoutesStoreClient struct { - grpc.ClientStream -} - -func (x *pieceStoreRoutesStoreClient) Send(m *PieceStore) error { - return x.ClientStream.SendMsg(m) -} - -func (x *pieceStoreRoutesStoreClient) CloseAndRecv() (*PieceStoreSummary, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(PieceStoreSummary) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *pieceStoreRoutesClient) Delete(ctx context.Context, in *PieceDelete, opts ...grpc.CallOption) (*PieceDeleteSummary, error) { - out := new(PieceDeleteSummary) - err := c.cc.Invoke(ctx, "/piecestoreroutes.PieceStoreRoutes/Delete", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PieceStoreRoutesServer is the server API for PieceStoreRoutes service. -type PieceStoreRoutesServer interface { - Piece(context.Context, *PieceId) (*PieceSummary, error) - Retrieve(PieceStoreRoutes_RetrieveServer) error - Store(PieceStoreRoutes_StoreServer) error - Delete(context.Context, *PieceDelete) (*PieceDeleteSummary, error) -} - -func RegisterPieceStoreRoutesServer(s *grpc.Server, srv PieceStoreRoutesServer) { - s.RegisterService(&_PieceStoreRoutes_serviceDesc, srv) -} - -func _PieceStoreRoutes_Piece_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PieceId) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PieceStoreRoutesServer).Piece(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/piecestoreroutes.PieceStoreRoutes/Piece", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PieceStoreRoutesServer).Piece(ctx, req.(*PieceId)) - } - return interceptor(ctx, in, info, handler) -} - -func _PieceStoreRoutes_Retrieve_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(PieceStoreRoutesServer).Retrieve(&pieceStoreRoutesRetrieveServer{stream}) -} - -type PieceStoreRoutes_RetrieveServer interface { - Send(*PieceRetrievalStream) error - Recv() (*PieceRetrieval, error) - grpc.ServerStream -} - -type pieceStoreRoutesRetrieveServer struct { - grpc.ServerStream -} - -func (x *pieceStoreRoutesRetrieveServer) Send(m *PieceRetrievalStream) error { - return x.ServerStream.SendMsg(m) -} - -func (x *pieceStoreRoutesRetrieveServer) Recv() (*PieceRetrieval, error) { - m := new(PieceRetrieval) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func _PieceStoreRoutes_Store_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(PieceStoreRoutesServer).Store(&pieceStoreRoutesStoreServer{stream}) -} - -type PieceStoreRoutes_StoreServer interface { - SendAndClose(*PieceStoreSummary) error - Recv() (*PieceStore, error) - grpc.ServerStream -} - -type pieceStoreRoutesStoreServer struct { - grpc.ServerStream -} - -func (x *pieceStoreRoutesStoreServer) SendAndClose(m *PieceStoreSummary) error { - return x.ServerStream.SendMsg(m) -} - -func (x *pieceStoreRoutesStoreServer) Recv() (*PieceStore, error) { - m := new(PieceStore) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func _PieceStoreRoutes_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PieceDelete) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PieceStoreRoutesServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/piecestoreroutes.PieceStoreRoutes/Delete", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PieceStoreRoutesServer).Delete(ctx, req.(*PieceDelete)) - } - return interceptor(ctx, in, info, handler) -} - -var _PieceStoreRoutes_serviceDesc = grpc.ServiceDesc{ - ServiceName: "piecestoreroutes.PieceStoreRoutes", - HandlerType: (*PieceStoreRoutesServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Piece", - Handler: _PieceStoreRoutes_Piece_Handler, - }, - { - MethodName: "Delete", - Handler: _PieceStoreRoutes_Delete_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Retrieve", - Handler: _PieceStoreRoutes_Retrieve_Handler, - ServerStreams: true, - ClientStreams: true, - }, - { - StreamName: "Store", - Handler: _PieceStoreRoutes_Store_Handler, - ClientStreams: true, - }, - }, - Metadata: "piecestore.proto", + // 548 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x53, 0x41, 0x4f, 0xdb, 0x3e, + 0x1c, 0x25, 0x4d, 0x5a, 0xc8, 0x8f, 0xb6, 0xe4, 0xef, 0x3f, 0x87, 0x80, 0xb6, 0xd1, 0xb1, 0x4b, + 0xc4, 0xa4, 0xa2, 0x31, 0x69, 0xd2, 0x8e, 0x54, 0x20, 0x56, 0x4d, 0x43, 0x95, 0x69, 0x2f, 0xdb, + 0x21, 0x73, 0xe3, 0xdf, 0x52, 0x8b, 0x10, 0x47, 0xb1, 0xa3, 0x15, 0xae, 0xfb, 0x72, 0xfb, 0x0c, + 0x3b, 0xf0, 0x41, 0x76, 0x9a, 0xe2, 0x40, 0xc3, 0xba, 0xf6, 0xe6, 0xf7, 0xfc, 0xf2, 0xfc, 0x7e, + 0x7e, 0x0e, 0x78, 0x99, 0xc0, 0x08, 0x95, 0x96, 0x39, 0xf6, 0xb3, 0x5c, 0x6a, 0x49, 0x9e, 0x30, + 0xb9, 0x2c, 0x34, 0xaa, 0x7d, 0x88, 0x65, 0x2c, 0xab, 0xdd, 0xfd, 0x17, 0xb1, 0x94, 0x71, 0x82, + 0xc7, 0x06, 0x4d, 0x8b, 0x6f, 0xc7, 0xbc, 0xc8, 0x99, 0x16, 0x32, 0xad, 0xf6, 0x0f, 0x7f, 0xd8, + 0xe0, 0x8f, 0xd8, 0x2d, 0xe6, 0x03, 0x96, 0xf2, 0xef, 0x82, 0xeb, 0xd9, 0x69, 0x92, 0xc8, 0xc8, + 0x48, 0xc8, 0x1b, 0x68, 0x2b, 0xa6, 0x31, 0x49, 0x84, 0xc6, 0x50, 0x70, 0xdf, 0xea, 0x59, 0x41, + 0x7b, 0xd0, 0xfd, 0x79, 0x7f, 0xb0, 0xf1, 0xeb, 0xfe, 0xa0, 0x75, 0x29, 0x39, 0x0e, 0xcf, 0xe8, + 0xf6, 0x42, 0x33, 0xe4, 0xe4, 0x35, 0xb8, 0x45, 0x96, 0x88, 0xf4, 0xba, 0xd4, 0x37, 0x56, 0xea, + 0xb7, 0x2a, 0xc1, 0x90, 0x93, 0x3d, 0xd8, 0xba, 0x61, 0xf3, 0x50, 0x89, 0x3b, 0xf4, 0xed, 0x9e, + 0x15, 0xd8, 0x74, 0xf3, 0x86, 0xcd, 0xaf, 0xc4, 0x1d, 0x92, 0x3e, 0xfc, 0x8f, 0xf3, 0x4c, 0x54, + 0x59, 0xc3, 0x22, 0x15, 0xf3, 0x50, 0x61, 0xe4, 0x3b, 0x46, 0xf5, 0x5f, 0xbd, 0x35, 0x49, 0xc5, + 0xfc, 0x0a, 0x23, 0xf2, 0x0a, 0x3a, 0x0a, 0x73, 0xc1, 0x92, 0x30, 0x2d, 0x6e, 0xa6, 0x98, 0xfb, + 0xcd, 0x9e, 0x15, 0xb8, 0xb4, 0x5d, 0x91, 0x97, 0x86, 0x23, 0xef, 0xa1, 0xc5, 0xa2, 0xf2, 0x2b, + 0xbf, 0xd5, 0xb3, 0x82, 0xee, 0xc9, 0xcb, 0xfe, 0xf2, 0xdd, 0xf5, 0xeb, 0x6b, 0x30, 0x42, 0xfa, + 0xf0, 0x01, 0x09, 0xc0, 0x8b, 0x72, 0x64, 0x1a, 0x79, 0x1d, 0x66, 0xd3, 0x84, 0xe9, 0x3e, 0xf0, + 0x8f, 0x49, 0x76, 0xa1, 0x19, 0x61, 0xae, 0x95, 0xbf, 0xd5, 0xb3, 0x83, 0x36, 0xad, 0x00, 0x79, + 0x06, 0xae, 0x12, 0x71, 0xca, 0x74, 0x91, 0xa3, 0xef, 0x96, 0xf7, 0x42, 0x6b, 0xe2, 0xf0, 0xb7, + 0x05, 0x7b, 0x14, 0x53, 0xbd, 0xba, 0x86, 0x2f, 0xe0, 0x65, 0x65, 0x45, 0x21, 0x5b, 0x70, 0xa6, + 0x8a, 0xed, 0x93, 0xa3, 0x7f, 0x07, 0x58, 0x57, 0xe6, 0xc0, 0x29, 0x6b, 0xa0, 0x3b, 0xc6, 0xe9, + 0x89, 0xf9, 0x2e, 0x34, 0xb5, 0xd4, 0x2c, 0x31, 0x65, 0xd9, 0xb4, 0x02, 0xe4, 0x1d, 0xec, 0x94, + 0xa6, 0x2c, 0xc6, 0x30, 0x95, 0xdc, 0x94, 0x6f, 0xaf, 0x2c, 0xb3, 0xf3, 0x20, 0x33, 0x90, 0xd7, + 0xc3, 0x3b, 0x6b, 0x87, 0x6f, 0x2e, 0x0f, 0xff, 0x15, 0x3a, 0x57, 0x22, 0x4e, 0x91, 0x7f, 0x42, + 0xa5, 0x58, 0x8c, 0x84, 0x80, 0xc3, 0x99, 0x66, 0xd5, 0x73, 0xa3, 0x66, 0xfd, 0xb7, 0x45, 0x63, + 0xc9, 0x82, 0x3c, 0x07, 0xc8, 0x8a, 0x69, 0x22, 0xa2, 0xf0, 0x1a, 0x6f, 0xab, 0xa4, 0xd4, 0xad, + 0x98, 0x8f, 0x78, 0x7b, 0x38, 0x06, 0xa8, 0x4e, 0xf8, 0xc0, 0xd4, 0xac, 0xb4, 0x9f, 0x31, 0x35, + 0x7b, 0xb4, 0x2f, 0xd7, 0x75, 0xee, 0xc6, 0xda, 0xdc, 0xf6, 0xd2, 0xa1, 0x47, 0x14, 0x76, 0x96, + 0x5e, 0x0b, 0xd9, 0x04, 0x7b, 0x34, 0x19, 0x7b, 0x1b, 0xe5, 0xe2, 0xe2, 0x7c, 0xec, 0x59, 0xa4, + 0x03, 0xee, 0xc5, 0xf9, 0x38, 0x3c, 0x9d, 0x9c, 0x0d, 0xc7, 0x5e, 0x83, 0x74, 0x01, 0x4a, 0x48, + 0xcf, 0x47, 0xa7, 0x43, 0xea, 0xd9, 0x25, 0x1e, 0x4d, 0x16, 0xd8, 0x19, 0x38, 0x9f, 0x1b, 0xd9, + 0x74, 0xda, 0x32, 0xff, 0xe6, 0xdb, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x31, 0xcd, 0xe9, + 0xed, 0x03, 0x00, 0x00, } diff --git a/pkg/pb/piecestore.pb.mock.go b/pkg/pb/piecestore.pb.mock.go deleted file mode 100644 index 580b6a41f..000000000 --- a/pkg/pb/piecestore.pb.mock.go +++ /dev/null @@ -1,740 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: piecestore.pb.go - -// Package pb is a generated GoMock package. -package pb - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" - grpc "google.golang.org/grpc" - metadata "google.golang.org/grpc/metadata" -) - -// MockPieceStoreRoutesClient is a mock of PieceStoreRoutesClient interface -type MockPieceStoreRoutesClient struct { - ctrl *gomock.Controller - recorder *MockPieceStoreRoutesClientMockRecorder -} - -// MockPieceStoreRoutesClientMockRecorder is the mock recorder for MockPieceStoreRoutesClient -type MockPieceStoreRoutesClientMockRecorder struct { - mock *MockPieceStoreRoutesClient -} - -// NewMockPieceStoreRoutesClient creates a new mock instance -func NewMockPieceStoreRoutesClient(ctrl *gomock.Controller) *MockPieceStoreRoutesClient { - mock := &MockPieceStoreRoutesClient{ctrl: ctrl} - mock.recorder = &MockPieceStoreRoutesClientMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockPieceStoreRoutesClient) EXPECT() *MockPieceStoreRoutesClientMockRecorder { - return m.recorder -} - -// Piece mocks base method -func (m *MockPieceStoreRoutesClient) Piece(ctx context.Context, in *PieceId, opts ...grpc.CallOption) (*PieceSummary, error) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx, in} - for _, a := range opts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Piece", varargs...) - ret0, _ := ret[0].(*PieceSummary) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Piece indicates an expected call of Piece -func (mr *MockPieceStoreRoutesClientMockRecorder) Piece(ctx, in interface{}, opts ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, in}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Piece", reflect.TypeOf((*MockPieceStoreRoutesClient)(nil).Piece), varargs...) -} - -// Retrieve mocks base method -func (m *MockPieceStoreRoutesClient) Retrieve(ctx context.Context, opts ...grpc.CallOption) (PieceStoreRoutes_RetrieveClient, error) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range opts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Retrieve", varargs...) - ret0, _ := ret[0].(PieceStoreRoutes_RetrieveClient) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Retrieve indicates an expected call of Retrieve -func (mr *MockPieceStoreRoutesClientMockRecorder) Retrieve(ctx interface{}, opts ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Retrieve", reflect.TypeOf((*MockPieceStoreRoutesClient)(nil).Retrieve), varargs...) -} - -// Store mocks base method -func (m *MockPieceStoreRoutesClient) Store(ctx context.Context, opts ...grpc.CallOption) (PieceStoreRoutes_StoreClient, error) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range opts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Store", varargs...) - ret0, _ := ret[0].(PieceStoreRoutes_StoreClient) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Store indicates an expected call of Store -func (mr *MockPieceStoreRoutesClientMockRecorder) Store(ctx interface{}, opts ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Store", reflect.TypeOf((*MockPieceStoreRoutesClient)(nil).Store), varargs...) -} - -// Delete mocks base method -func (m *MockPieceStoreRoutesClient) Delete(ctx context.Context, in *PieceDelete, opts ...grpc.CallOption) (*PieceDeleteSummary, error) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx, in} - for _, a := range opts { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Delete", varargs...) - ret0, _ := ret[0].(*PieceDeleteSummary) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Delete indicates an expected call of Delete -func (mr *MockPieceStoreRoutesClientMockRecorder) Delete(ctx, in interface{}, opts ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, in}, opts...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockPieceStoreRoutesClient)(nil).Delete), varargs...) -} - -// MockPieceStoreRoutes_RetrieveClient is a mock of PieceStoreRoutes_RetrieveClient interface -type MockPieceStoreRoutes_RetrieveClient struct { - ctrl *gomock.Controller - recorder *MockPieceStoreRoutes_RetrieveClientMockRecorder -} - -// MockPieceStoreRoutes_RetrieveClientMockRecorder is the mock recorder for MockPieceStoreRoutes_RetrieveClient -type MockPieceStoreRoutes_RetrieveClientMockRecorder struct { - mock *MockPieceStoreRoutes_RetrieveClient -} - -// NewMockPieceStoreRoutes_RetrieveClient creates a new mock instance -func NewMockPieceStoreRoutes_RetrieveClient(ctrl *gomock.Controller) *MockPieceStoreRoutes_RetrieveClient { - mock := &MockPieceStoreRoutes_RetrieveClient{ctrl: ctrl} - mock.recorder = &MockPieceStoreRoutes_RetrieveClientMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockPieceStoreRoutes_RetrieveClient) EXPECT() *MockPieceStoreRoutes_RetrieveClientMockRecorder { - return m.recorder -} - -// Send mocks base method -func (m *MockPieceStoreRoutes_RetrieveClient) Send(arg0 *PieceRetrieval) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Send", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Send indicates an expected call of Send -func (mr *MockPieceStoreRoutes_RetrieveClientMockRecorder) Send(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveClient)(nil).Send), arg0) -} - -// Recv mocks base method -func (m *MockPieceStoreRoutes_RetrieveClient) Recv() (*PieceRetrievalStream, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Recv") - ret0, _ := ret[0].(*PieceRetrievalStream) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Recv indicates an expected call of Recv -func (mr *MockPieceStoreRoutes_RetrieveClientMockRecorder) Recv() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveClient)(nil).Recv)) -} - -// Header mocks base method -func (m *MockPieceStoreRoutes_RetrieveClient) Header() (metadata.MD, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Header") - ret0, _ := ret[0].(metadata.MD) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Header indicates an expected call of Header -func (mr *MockPieceStoreRoutes_RetrieveClientMockRecorder) Header() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Header", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveClient)(nil).Header)) -} - -// Trailer mocks base method -func (m *MockPieceStoreRoutes_RetrieveClient) Trailer() metadata.MD { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Trailer") - ret0, _ := ret[0].(metadata.MD) - return ret0 -} - -// Trailer indicates an expected call of Trailer -func (mr *MockPieceStoreRoutes_RetrieveClientMockRecorder) Trailer() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Trailer", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveClient)(nil).Trailer)) -} - -// CloseSend mocks base method -func (m *MockPieceStoreRoutes_RetrieveClient) CloseSend() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CloseSend") - ret0, _ := ret[0].(error) - return ret0 -} - -// CloseSend indicates an expected call of CloseSend -func (mr *MockPieceStoreRoutes_RetrieveClientMockRecorder) CloseSend() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseSend", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveClient)(nil).CloseSend)) -} - -// Context mocks base method -func (m *MockPieceStoreRoutes_RetrieveClient) Context() context.Context { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Context") - ret0, _ := ret[0].(context.Context) - return ret0 -} - -// Context indicates an expected call of Context -func (mr *MockPieceStoreRoutes_RetrieveClientMockRecorder) Context() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveClient)(nil).Context)) -} - -// SendMsg mocks base method -func (m_2 *MockPieceStoreRoutes_RetrieveClient) SendMsg(m interface{}) error { - m_2.ctrl.T.Helper() - ret := m_2.ctrl.Call(m_2, "SendMsg", m) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendMsg indicates an expected call of SendMsg -func (mr *MockPieceStoreRoutes_RetrieveClientMockRecorder) SendMsg(m interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveClient)(nil).SendMsg), m) -} - -// RecvMsg mocks base method -func (m_2 *MockPieceStoreRoutes_RetrieveClient) RecvMsg(m interface{}) error { - m_2.ctrl.T.Helper() - ret := m_2.ctrl.Call(m_2, "RecvMsg", m) - ret0, _ := ret[0].(error) - return ret0 -} - -// RecvMsg indicates an expected call of RecvMsg -func (mr *MockPieceStoreRoutes_RetrieveClientMockRecorder) RecvMsg(m interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveClient)(nil).RecvMsg), m) -} - -// MockPieceStoreRoutes_StoreClient is a mock of PieceStoreRoutes_StoreClient interface -type MockPieceStoreRoutes_StoreClient struct { - ctrl *gomock.Controller - recorder *MockPieceStoreRoutes_StoreClientMockRecorder -} - -// MockPieceStoreRoutes_StoreClientMockRecorder is the mock recorder for MockPieceStoreRoutes_StoreClient -type MockPieceStoreRoutes_StoreClientMockRecorder struct { - mock *MockPieceStoreRoutes_StoreClient -} - -// NewMockPieceStoreRoutes_StoreClient creates a new mock instance -func NewMockPieceStoreRoutes_StoreClient(ctrl *gomock.Controller) *MockPieceStoreRoutes_StoreClient { - mock := &MockPieceStoreRoutes_StoreClient{ctrl: ctrl} - mock.recorder = &MockPieceStoreRoutes_StoreClientMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockPieceStoreRoutes_StoreClient) EXPECT() *MockPieceStoreRoutes_StoreClientMockRecorder { - return m.recorder -} - -// Send mocks base method -func (m *MockPieceStoreRoutes_StoreClient) Send(arg0 *PieceStore) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Send", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Send indicates an expected call of Send -func (mr *MockPieceStoreRoutes_StoreClientMockRecorder) Send(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockPieceStoreRoutes_StoreClient)(nil).Send), arg0) -} - -// CloseAndRecv mocks base method -func (m *MockPieceStoreRoutes_StoreClient) CloseAndRecv() (*PieceStoreSummary, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CloseAndRecv") - ret0, _ := ret[0].(*PieceStoreSummary) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CloseAndRecv indicates an expected call of CloseAndRecv -func (mr *MockPieceStoreRoutes_StoreClientMockRecorder) CloseAndRecv() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseAndRecv", reflect.TypeOf((*MockPieceStoreRoutes_StoreClient)(nil).CloseAndRecv)) -} - -// Header mocks base method -func (m *MockPieceStoreRoutes_StoreClient) Header() (metadata.MD, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Header") - ret0, _ := ret[0].(metadata.MD) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Header indicates an expected call of Header -func (mr *MockPieceStoreRoutes_StoreClientMockRecorder) Header() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Header", reflect.TypeOf((*MockPieceStoreRoutes_StoreClient)(nil).Header)) -} - -// Trailer mocks base method -func (m *MockPieceStoreRoutes_StoreClient) Trailer() metadata.MD { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Trailer") - ret0, _ := ret[0].(metadata.MD) - return ret0 -} - -// Trailer indicates an expected call of Trailer -func (mr *MockPieceStoreRoutes_StoreClientMockRecorder) Trailer() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Trailer", reflect.TypeOf((*MockPieceStoreRoutes_StoreClient)(nil).Trailer)) -} - -// CloseSend mocks base method -func (m *MockPieceStoreRoutes_StoreClient) CloseSend() error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CloseSend") - ret0, _ := ret[0].(error) - return ret0 -} - -// CloseSend indicates an expected call of CloseSend -func (mr *MockPieceStoreRoutes_StoreClientMockRecorder) CloseSend() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseSend", reflect.TypeOf((*MockPieceStoreRoutes_StoreClient)(nil).CloseSend)) -} - -// Context mocks base method -func (m *MockPieceStoreRoutes_StoreClient) Context() context.Context { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Context") - ret0, _ := ret[0].(context.Context) - return ret0 -} - -// Context indicates an expected call of Context -func (mr *MockPieceStoreRoutes_StoreClientMockRecorder) Context() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockPieceStoreRoutes_StoreClient)(nil).Context)) -} - -// SendMsg mocks base method -func (m_2 *MockPieceStoreRoutes_StoreClient) SendMsg(m interface{}) error { - m_2.ctrl.T.Helper() - ret := m_2.ctrl.Call(m_2, "SendMsg", m) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendMsg indicates an expected call of SendMsg -func (mr *MockPieceStoreRoutes_StoreClientMockRecorder) SendMsg(m interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockPieceStoreRoutes_StoreClient)(nil).SendMsg), m) -} - -// RecvMsg mocks base method -func (m_2 *MockPieceStoreRoutes_StoreClient) RecvMsg(m interface{}) error { - m_2.ctrl.T.Helper() - ret := m_2.ctrl.Call(m_2, "RecvMsg", m) - ret0, _ := ret[0].(error) - return ret0 -} - -// RecvMsg indicates an expected call of RecvMsg -func (mr *MockPieceStoreRoutes_StoreClientMockRecorder) RecvMsg(m interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockPieceStoreRoutes_StoreClient)(nil).RecvMsg), m) -} - -// MockPieceStoreRoutesServer is a mock of PieceStoreRoutesServer interface -type MockPieceStoreRoutesServer struct { - ctrl *gomock.Controller - recorder *MockPieceStoreRoutesServerMockRecorder -} - -// MockPieceStoreRoutesServerMockRecorder is the mock recorder for MockPieceStoreRoutesServer -type MockPieceStoreRoutesServerMockRecorder struct { - mock *MockPieceStoreRoutesServer -} - -// NewMockPieceStoreRoutesServer creates a new mock instance -func NewMockPieceStoreRoutesServer(ctrl *gomock.Controller) *MockPieceStoreRoutesServer { - mock := &MockPieceStoreRoutesServer{ctrl: ctrl} - mock.recorder = &MockPieceStoreRoutesServerMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockPieceStoreRoutesServer) EXPECT() *MockPieceStoreRoutesServerMockRecorder { - return m.recorder -} - -// Piece mocks base method -func (m *MockPieceStoreRoutesServer) Piece(arg0 context.Context, arg1 *PieceId) (*PieceSummary, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Piece", arg0, arg1) - ret0, _ := ret[0].(*PieceSummary) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Piece indicates an expected call of Piece -func (mr *MockPieceStoreRoutesServerMockRecorder) Piece(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Piece", reflect.TypeOf((*MockPieceStoreRoutesServer)(nil).Piece), arg0, arg1) -} - -// Retrieve mocks base method -func (m *MockPieceStoreRoutesServer) Retrieve(arg0 PieceStoreRoutes_RetrieveServer) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Retrieve", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Retrieve indicates an expected call of Retrieve -func (mr *MockPieceStoreRoutesServerMockRecorder) Retrieve(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Retrieve", reflect.TypeOf((*MockPieceStoreRoutesServer)(nil).Retrieve), arg0) -} - -// Store mocks base method -func (m *MockPieceStoreRoutesServer) Store(arg0 PieceStoreRoutes_StoreServer) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Store", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Store indicates an expected call of Store -func (mr *MockPieceStoreRoutesServerMockRecorder) Store(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Store", reflect.TypeOf((*MockPieceStoreRoutesServer)(nil).Store), arg0) -} - -// Delete mocks base method -func (m *MockPieceStoreRoutesServer) Delete(arg0 context.Context, arg1 *PieceDelete) (*PieceDeleteSummary, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Delete", arg0, arg1) - ret0, _ := ret[0].(*PieceDeleteSummary) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Delete indicates an expected call of Delete -func (mr *MockPieceStoreRoutesServerMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockPieceStoreRoutesServer)(nil).Delete), arg0, arg1) -} - -// MockPieceStoreRoutes_RetrieveServer is a mock of PieceStoreRoutes_RetrieveServer interface -type MockPieceStoreRoutes_RetrieveServer struct { - ctrl *gomock.Controller - recorder *MockPieceStoreRoutes_RetrieveServerMockRecorder -} - -// MockPieceStoreRoutes_RetrieveServerMockRecorder is the mock recorder for MockPieceStoreRoutes_RetrieveServer -type MockPieceStoreRoutes_RetrieveServerMockRecorder struct { - mock *MockPieceStoreRoutes_RetrieveServer -} - -// NewMockPieceStoreRoutes_RetrieveServer creates a new mock instance -func NewMockPieceStoreRoutes_RetrieveServer(ctrl *gomock.Controller) *MockPieceStoreRoutes_RetrieveServer { - mock := &MockPieceStoreRoutes_RetrieveServer{ctrl: ctrl} - mock.recorder = &MockPieceStoreRoutes_RetrieveServerMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockPieceStoreRoutes_RetrieveServer) EXPECT() *MockPieceStoreRoutes_RetrieveServerMockRecorder { - return m.recorder -} - -// Send mocks base method -func (m *MockPieceStoreRoutes_RetrieveServer) Send(arg0 *PieceRetrievalStream) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Send", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// Send indicates an expected call of Send -func (mr *MockPieceStoreRoutes_RetrieveServerMockRecorder) Send(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveServer)(nil).Send), arg0) -} - -// Recv mocks base method -func (m *MockPieceStoreRoutes_RetrieveServer) Recv() (*PieceRetrieval, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Recv") - ret0, _ := ret[0].(*PieceRetrieval) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Recv indicates an expected call of Recv -func (mr *MockPieceStoreRoutes_RetrieveServerMockRecorder) Recv() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveServer)(nil).Recv)) -} - -// SetHeader mocks base method -func (m *MockPieceStoreRoutes_RetrieveServer) SetHeader(arg0 metadata.MD) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetHeader", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetHeader indicates an expected call of SetHeader -func (mr *MockPieceStoreRoutes_RetrieveServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveServer)(nil).SetHeader), arg0) -} - -// SendHeader mocks base method -func (m *MockPieceStoreRoutes_RetrieveServer) SendHeader(arg0 metadata.MD) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendHeader", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendHeader indicates an expected call of SendHeader -func (mr *MockPieceStoreRoutes_RetrieveServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveServer)(nil).SendHeader), arg0) -} - -// SetTrailer mocks base method -func (m *MockPieceStoreRoutes_RetrieveServer) SetTrailer(arg0 metadata.MD) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetTrailer", arg0) -} - -// SetTrailer indicates an expected call of SetTrailer -func (mr *MockPieceStoreRoutes_RetrieveServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveServer)(nil).SetTrailer), arg0) -} - -// Context mocks base method -func (m *MockPieceStoreRoutes_RetrieveServer) Context() context.Context { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Context") - ret0, _ := ret[0].(context.Context) - return ret0 -} - -// Context indicates an expected call of Context -func (mr *MockPieceStoreRoutes_RetrieveServerMockRecorder) Context() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveServer)(nil).Context)) -} - -// SendMsg mocks base method -func (m_2 *MockPieceStoreRoutes_RetrieveServer) SendMsg(m interface{}) error { - m_2.ctrl.T.Helper() - ret := m_2.ctrl.Call(m_2, "SendMsg", m) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendMsg indicates an expected call of SendMsg -func (mr *MockPieceStoreRoutes_RetrieveServerMockRecorder) SendMsg(m interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveServer)(nil).SendMsg), m) -} - -// RecvMsg mocks base method -func (m_2 *MockPieceStoreRoutes_RetrieveServer) RecvMsg(m interface{}) error { - m_2.ctrl.T.Helper() - ret := m_2.ctrl.Call(m_2, "RecvMsg", m) - ret0, _ := ret[0].(error) - return ret0 -} - -// RecvMsg indicates an expected call of RecvMsg -func (mr *MockPieceStoreRoutes_RetrieveServerMockRecorder) RecvMsg(m interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockPieceStoreRoutes_RetrieveServer)(nil).RecvMsg), m) -} - -// MockPieceStoreRoutes_StoreServer is a mock of PieceStoreRoutes_StoreServer interface -type MockPieceStoreRoutes_StoreServer struct { - ctrl *gomock.Controller - recorder *MockPieceStoreRoutes_StoreServerMockRecorder -} - -// MockPieceStoreRoutes_StoreServerMockRecorder is the mock recorder for MockPieceStoreRoutes_StoreServer -type MockPieceStoreRoutes_StoreServerMockRecorder struct { - mock *MockPieceStoreRoutes_StoreServer -} - -// NewMockPieceStoreRoutes_StoreServer creates a new mock instance -func NewMockPieceStoreRoutes_StoreServer(ctrl *gomock.Controller) *MockPieceStoreRoutes_StoreServer { - mock := &MockPieceStoreRoutes_StoreServer{ctrl: ctrl} - mock.recorder = &MockPieceStoreRoutes_StoreServerMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use -func (m *MockPieceStoreRoutes_StoreServer) EXPECT() *MockPieceStoreRoutes_StoreServerMockRecorder { - return m.recorder -} - -// SendAndClose mocks base method -func (m *MockPieceStoreRoutes_StoreServer) SendAndClose(arg0 *PieceStoreSummary) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendAndClose", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendAndClose indicates an expected call of SendAndClose -func (mr *MockPieceStoreRoutes_StoreServerMockRecorder) SendAndClose(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendAndClose", reflect.TypeOf((*MockPieceStoreRoutes_StoreServer)(nil).SendAndClose), arg0) -} - -// Recv mocks base method -func (m *MockPieceStoreRoutes_StoreServer) Recv() (*PieceStore, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Recv") - ret0, _ := ret[0].(*PieceStore) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Recv indicates an expected call of Recv -func (mr *MockPieceStoreRoutes_StoreServerMockRecorder) Recv() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Recv", reflect.TypeOf((*MockPieceStoreRoutes_StoreServer)(nil).Recv)) -} - -// SetHeader mocks base method -func (m *MockPieceStoreRoutes_StoreServer) SetHeader(arg0 metadata.MD) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetHeader", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetHeader indicates an expected call of SetHeader -func (mr *MockPieceStoreRoutes_StoreServerMockRecorder) SetHeader(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetHeader", reflect.TypeOf((*MockPieceStoreRoutes_StoreServer)(nil).SetHeader), arg0) -} - -// SendHeader mocks base method -func (m *MockPieceStoreRoutes_StoreServer) SendHeader(arg0 metadata.MD) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SendHeader", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendHeader indicates an expected call of SendHeader -func (mr *MockPieceStoreRoutes_StoreServerMockRecorder) SendHeader(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendHeader", reflect.TypeOf((*MockPieceStoreRoutes_StoreServer)(nil).SendHeader), arg0) -} - -// SetTrailer mocks base method -func (m *MockPieceStoreRoutes_StoreServer) SetTrailer(arg0 metadata.MD) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetTrailer", arg0) -} - -// SetTrailer indicates an expected call of SetTrailer -func (mr *MockPieceStoreRoutes_StoreServerMockRecorder) SetTrailer(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTrailer", reflect.TypeOf((*MockPieceStoreRoutes_StoreServer)(nil).SetTrailer), arg0) -} - -// Context mocks base method -func (m *MockPieceStoreRoutes_StoreServer) Context() context.Context { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Context") - ret0, _ := ret[0].(context.Context) - return ret0 -} - -// Context indicates an expected call of Context -func (mr *MockPieceStoreRoutes_StoreServerMockRecorder) Context() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Context", reflect.TypeOf((*MockPieceStoreRoutes_StoreServer)(nil).Context)) -} - -// SendMsg mocks base method -func (m_2 *MockPieceStoreRoutes_StoreServer) SendMsg(m interface{}) error { - m_2.ctrl.T.Helper() - ret := m_2.ctrl.Call(m_2, "SendMsg", m) - ret0, _ := ret[0].(error) - return ret0 -} - -// SendMsg indicates an expected call of SendMsg -func (mr *MockPieceStoreRoutes_StoreServerMockRecorder) SendMsg(m interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendMsg", reflect.TypeOf((*MockPieceStoreRoutes_StoreServer)(nil).SendMsg), m) -} - -// RecvMsg mocks base method -func (m_2 *MockPieceStoreRoutes_StoreServer) RecvMsg(m interface{}) error { - m_2.ctrl.T.Helper() - ret := m_2.ctrl.Call(m_2, "RecvMsg", m) - ret0, _ := ret[0].(error) - return ret0 -} - -// RecvMsg indicates an expected call of RecvMsg -func (mr *MockPieceStoreRoutes_StoreServerMockRecorder) RecvMsg(m interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RecvMsg", reflect.TypeOf((*MockPieceStoreRoutes_StoreServer)(nil).RecvMsg), m) -} diff --git a/pkg/pb/piecestore.proto b/pkg/pb/piecestore.proto index 8668388fa..34824a0bf 100644 --- a/pkg/pb/piecestore.proto +++ b/pkg/pb/piecestore.proto @@ -9,13 +9,6 @@ package piecestoreroutes; import "gogo.proto"; import "google/protobuf/duration.proto"; -service PieceStoreRoutes { - rpc Piece(PieceId) returns (PieceSummary) {} - rpc Retrieve(stream PieceRetrieval) returns (stream PieceRetrievalStream) {} - rpc Store(stream PieceStore) returns (PieceStoreSummary) {} - rpc Delete(PieceDelete) returns (PieceDeleteSummary) {} -} - enum BandwidthAction { PUT = 0; GET = 1; @@ -46,69 +39,6 @@ message RenterBandwidthAllocation { // Renter refers to uplink bytes signature = 5; // Proof that the data was signed by the Uplink } -message PieceStore { - message PieceData { - // TODO: may want to use customtype and fixed-length byte slice - string id = 1; - int64 expiration_unix_sec = 2; - bytes content = 3; - } - - RenterBandwidthAllocation bandwidth_allocation = 1; - PieceData piece_data = 2; - SignedMessage authorization = 3 [deprecated=true]; - SignedHash signed_hash = 4; -} - -message PieceId { - // TODO: may want to use customtype and fixed-length byte slice - string id = 1; - - SignedMessage authorization = 2 [deprecated=true]; - bytes satellite_id = 3 [(gogoproto.customtype) = "NodeID", (gogoproto.nullable) = false]; -} - -message PieceSummary { - string id = 1; - int64 piece_size = 2; - int64 expiration_unix_sec = 3; -} - -message PieceRetrieval { - message PieceData { - // TODO: may want to use customtype and fixed-length byte slice - string id = 1; - int64 piece_size = 2; - int64 offset = 3; - } - - RenterBandwidthAllocation bandwidth_allocation = 1; - PieceData piece_data = 2; - SignedMessage authorization = 3 [deprecated=true]; -} - -message PieceRetrievalStream { - int64 piece_size = 1; - bytes content = 2; -} - -message PieceDelete { - // TODO: may want to use customtype and fixed-length byte slice - string id = 1; - SignedMessage authorization = 3 [deprecated=true]; - bytes satellite_id = 4 [(gogoproto.customtype) = "NodeID", (gogoproto.nullable) = false]; -} - -message PieceDeleteSummary { - string message = 1; -} - -message PieceStoreSummary { - string message = 1; - int64 total_received = 2; - SignedHash signed_hash = 3; -} - message SignedMessage { bytes data = 1; bytes signature = 2; diff --git a/pkg/piecestore/psserver/bucket_refresher.go b/pkg/piecestore/psserver/bucket_refresher.go deleted file mode 100644 index b2ecefd01..000000000 --- a/pkg/piecestore/psserver/bucket_refresher.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package psserver - -import ( - "context" - "time" - - "github.com/zeebo/errs" - "go.uber.org/zap" - - "storj.io/storj/pkg/kademlia" - "storj.io/storj/pkg/pb" -) - -var ( - // Error is a standard error class for this package. - Error = errs.Class("kademlia bucket refresher error") -) - -// Monitor contains the information needed to run the bucket refresher service -type Monitor struct { // TODO: rename to something clearer - log *zap.Logger - ticker *time.Ticker - rt *kademlia.RoutingTable - server *Server - inspector *Inspector -} - -// NewMonitor creates a disk monitor -func NewMonitor(log *zap.Logger, interval time.Duration, rt *kademlia.RoutingTable, server *Server) *Monitor { - return &Monitor{ - log: log, - ticker: time.NewTicker(interval), - rt: rt, - server: server, - inspector: NewInspector(server), - } -} - -// Run runs the bucket refresher service -func (service *Monitor) Run(ctx context.Context) error { - for { - err := service.process(ctx) - if err != nil { - service.log.Error("process", zap.Error(err)) - } - - select { - case <-service.ticker.C: // wait for the next interval to happen - case <-ctx.Done(): // or the bucket refresher service is canceled via context - return ctx.Err() - } - } -} - -// process will attempt to update the kademlia bucket with the latest information about the storage node -func (service *Monitor) process(ctx context.Context) error { - stats, err := service.inspector.Stats(ctx, nil) - if err != nil { - return Error.Wrap(err) - } - - self := service.rt.Local() - - self.Restrictions = &pb.NodeRestrictions{ - FreeBandwidth: stats.AvailableBandwidth, - FreeDisk: stats.AvailableSpace, - } - - // Update the routing table with latest restrictions - if err := service.rt.UpdateSelf(&self); err != nil { - return Error.Wrap(err) - } - - return nil -} diff --git a/pkg/piecestore/psserver/collector.go b/pkg/piecestore/psserver/collector.go deleted file mode 100644 index 944c9e859..000000000 --- a/pkg/piecestore/psserver/collector.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package psserver - -import ( - "context" - "time" - - "github.com/zeebo/errs" - "go.uber.org/zap" - - "storj.io/storj/pkg/piecestore/psserver/psdb" -) - -// ErrorCollector is error class for piece collector -var ErrorCollector = errs.Class("piecestore collector") - -// Collector collects expired pieces from database and disk. -type Collector struct { - log *zap.Logger - db *psdb.DB - storage Storage - - interval time.Duration -} - -// NewCollector returns a new piece collector -func NewCollector(log *zap.Logger, db *psdb.DB, storage Storage, interval time.Duration) *Collector { - return &Collector{ - log: log, - db: db, - storage: storage, - interval: interval, - } -} - -// Run runs the collector at regular intervals -func (service *Collector) Run(ctx context.Context) error { - ticker := time.NewTicker(service.interval) - defer ticker.Stop() - - for { - err := service.Collect(ctx) - if err != nil { - service.log.Error("collect", zap.Error(err)) - } - - select { - case <-ticker.C: // wait for the next interval to happen - case <-ctx.Done(): // or the bucket refresher service is canceled via context - return ctx.Err() - } - } -} - -// Collect collects expired pieces att this moment. -func (service *Collector) Collect(ctx context.Context) error { - for { - expired, err := service.db.DeleteExpired(ctx) - if err != nil { - return ErrorCollector.Wrap(err) - } - if len(expired) == 0 { - return nil - } - - var errlist errs.Group - for _, id := range expired { - errlist.Add(service.storage.Delete(id)) - } - - if err := errlist.Err(); err != nil { - return ErrorCollector.Wrap(err) - } - } -} diff --git a/pkg/piecestore/psserver/config.go b/pkg/piecestore/psserver/config.go index 2e1fcc68a..3908dc248 100644 --- a/pkg/piecestore/psserver/config.go +++ b/pkg/piecestore/psserver/config.go @@ -6,15 +6,9 @@ package psserver import ( "time" - monkit "gopkg.in/spacemonkeygo/monkit.v2" - "storj.io/storj/internal/memory" ) -var ( - mon = monkit.Package() -) - // Config contains everything necessary for a server type Config struct { Path string `help:"path to store data in" default:"$CONFDIR/storage"` diff --git a/pkg/piecestore/psserver/inspector.go b/pkg/piecestore/psserver/inspector.go deleted file mode 100644 index 8cac30001..000000000 --- a/pkg/piecestore/psserver/inspector.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package psserver - -import ( - "context" - "strings" - "time" - - "github.com/golang/protobuf/ptypes" - "go.uber.org/zap" - - "storj.io/storj/pkg/pb" - "storj.io/storj/pkg/storj" -) - -// Inspector is a gRPC service for inspecting psserver internals -type Inspector struct { - ps *Server -} - -// NewInspector creates an Inspector -func NewInspector(psserver *Server) *Inspector { - return &Inspector{ - ps: psserver, - } -} - -func (s *Inspector) retrieveStats() (*pb.StatSummaryResponse, error) { - totalUsed, err := s.ps.DB.SumTTLSizes() - if err != nil { - return nil, err - } - - totalUsedBandwidth, err := s.ps.DB.GetTotalBandwidthBetween(getBeginningOfMonth(), time.Now()) - if err != nil { - return nil, err - } - - return &pb.StatSummaryResponse{ - UsedSpace: totalUsed, - AvailableSpace: (s.ps.totalAllocated - totalUsed), - UsedBandwidth: totalUsedBandwidth, - AvailableBandwidth: (s.ps.totalBwAllocated - totalUsedBandwidth), - }, nil -} - -// Stats returns current statistics about the server. -func (s *Inspector) Stats(ctx context.Context, in *pb.StatsRequest) (*pb.StatSummaryResponse, error) { - s.ps.log.Debug("Getting Stats...") - - statsSummary, err := s.retrieveStats() - if err != nil { - return nil, err - } - - s.ps.log.Info("Successfully retrieved Stats...") - - return statsSummary, nil -} - -func (s *Inspector) getDashboardData(ctx context.Context) (*pb.DashboardResponse, error) { - statsSummary, err := s.retrieveStats() - if err != nil { - return &pb.DashboardResponse{}, ServerError.Wrap(err) - } - - nodes, err := s.ps.kad.FindNear(ctx, storj.NodeID{}, 10000000) - if err != nil { - return &pb.DashboardResponse{}, ServerError.Wrap(err) - } - - bootstrapNodes := s.ps.kad.GetBootstrapNodes() - - bsNodes := make([]string, len(bootstrapNodes)) - - for i, node := range bootstrapNodes { - bsNodes[i] = node.Address.Address - } - - pinged, err := ptypes.TimestampProto(s.ps.kad.LastPinged()) - if err != nil { - s.ps.log.Warn("last ping time bad", zap.Error(err)) - pinged = nil - } - queried, err := ptypes.TimestampProto(s.ps.kad.LastQueried()) - if err != nil { - s.ps.log.Warn("last query time bad", zap.Error(err)) - queried = nil - } - - return &pb.DashboardResponse{ - NodeId: s.ps.kad.Local().Id, - NodeConnections: int64(len(nodes)), - BootstrapAddress: strings.Join(bsNodes[:], ", "), - InternalAddress: "", - ExternalAddress: s.ps.kad.Local().Address.Address, - LastPinged: pinged, - LastQueried: queried, - Uptime: ptypes.DurationProto(time.Since(s.ps.startTime)), - Stats: statsSummary, - }, nil -} - -// Dashboard returns dashboard data. -func (s *Inspector) Dashboard(ctx context.Context, in *pb.DashboardRequest) (*pb.DashboardResponse, error) { - data, err := s.getDashboardData(ctx) - if err != nil { - s.ps.log.Warn("unable to create dashboard data proto") - return nil, err - } - return data, nil -} diff --git a/pkg/piecestore/psserver/readerwriter.go b/pkg/piecestore/psserver/readerwriter.go deleted file mode 100644 index 7a3567301..000000000 --- a/pkg/piecestore/psserver/readerwriter.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package psserver - -import ( - "crypto/sha256" - "hash" - - "github.com/zeebo/errs" - - "storj.io/storj/pkg/pb" - "storj.io/storj/pkg/utils" -) - -// StreamWriterError is a type of error for failures in StreamWriter -var StreamWriterError = errs.Class("stream writer error") - -// StreamWriter -- Struct for writing piece to server upload stream -type StreamWriter struct { - server *Server - stream pb.PieceStoreRoutes_RetrieveServer -} - -// NewStreamWriter returns a new StreamWriter -func NewStreamWriter(s *Server, stream pb.PieceStoreRoutes_RetrieveServer) *StreamWriter { - return &StreamWriter{server: s, stream: stream} -} - -// Write -- Write method for piece upload to stream for Server.Retrieve -func (s *StreamWriter) Write(b []byte) (int, error) { - // Write the buffer to the stream we opened earlier - if err := s.stream.Send(&pb.PieceRetrievalStream{PieceSize: int64(len(b)), Content: b}); err != nil { - return 0, err - } - - return len(b), nil -} - -// StreamReader is a struct for Retrieving data from server -type StreamReader struct { - src *utils.ReaderSource - bandwidthAllocation *pb.Order - currentTotal int64 - bandwidthRemaining int64 - spaceRemaining int64 - sofar int64 - hash hash.Hash -} - -// NewStreamReader returns a new StreamReader for Server.Store -func NewStreamReader(s *Server, stream pb.PieceStoreRoutes_StoreServer, bandwidthRemaining, spaceRemaining int64) *StreamReader { - sr := &StreamReader{ - bandwidthRemaining: bandwidthRemaining, - spaceRemaining: spaceRemaining, - hash: sha256.New(), - } - sr.src = utils.NewReaderSource(func() ([]byte, error) { - - recv, err := stream.Recv() - if err != nil { - return nil, err - } - - pd := recv.GetPieceData() - rba := recv.BandwidthAllocation - - if err = s.verifySignature(stream.Context(), rba); err != nil { - return nil, err - } - pba := rba.PayerAllocation - if err = s.verifyPayerAllocation(&pba, "PUT"); err != nil { - return nil, err - } - // if whitelist does not contain PBA satellite ID, reject storage request - if len(s.whitelist) != 0 { - if !s.isWhitelisted(pba.SatelliteId) { - return nil, StoreError.New("Satellite ID not approved") - } - } - // Update bandwidthallocation to be stored - if rba.Total > sr.currentTotal { - sr.bandwidthAllocation = rba - sr.currentTotal = rba.Total - } - return pd.GetContent(), nil - }) - - return sr -} - -// Read reads piece from stream -func (s *StreamReader) Read(b []byte) (int, error) { - if s.sofar >= s.bandwidthRemaining { - return 0, StreamWriterError.New("out of bandwidth") - } - if s.sofar >= s.spaceRemaining { - return 0, StreamWriterError.New("out of space") - } - - n, err := s.src.Read(b) - s.sofar += int64(n) - _, errHash := s.hash.Write(b[:n]) - err = errs.Combine(err, errHash) - if err != nil { - return n, err - } - - if s.sofar >= s.spaceRemaining { - return n, StreamWriterError.New("out of space") - } - - return n, nil -} diff --git a/pkg/piecestore/psserver/readerwriter_test.go b/pkg/piecestore/psserver/readerwriter_test.go deleted file mode 100644 index fc735c4e0..000000000 --- a/pkg/piecestore/psserver/readerwriter_test.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package psserver - -import ( - "crypto/sha256" - "io" - "testing" - - "github.com/stretchr/testify/assert" - - "storj.io/storj/pkg/utils" -) - -func TestRead(t *testing.T) { - for _, tt := range []struct { - name string - file []byte - outputBufLen int - bwLeft int64 - spaceLeft int64 - n int - eofErr bool - bwErr bool - spaceErr bool - }{ - {"Test EOF error: ", []byte("abcdefghijklmnopqrstuvwxyz"), 30, 40, 40, 26, true, false, false}, - {"Test exceeds bandwidth error: ", []byte("abcdefghijklmnopqrstuvwxyz"), 26, 5, 40, 10, false, true, false}, - {"Test exceeds space error 1: ", []byte("abcdefghijklmnopqrstuvwxyz"), 26, 40, 5, 10, false, false, true}, - {"Test exceeds space error 2: ", []byte("abcdefghijklmnopqrstuvwxyz"), 26, 40, 0, 0, false, false, true}, - {"Test no error: ", []byte("abcdefghijklmnopqrstuvwxyz"), 20, 40, 40, 20, false, false, false}, - } { - sum := sha256.Sum256(tt.file[:tt.n]) - expectedHash := sum[:] - - remaining := tt.file - readerSrc := utils.NewReaderSource(func() ([]byte, error) { - if len(remaining) == 0 { - return nil, io.EOF - } - - // send in 10 byte chunks - if len(remaining) <= 10 { - ret := remaining - remaining = []byte{} - return ret, io.EOF - } - - ret := remaining[:10] - remaining = remaining[10:] - - return ret, nil - }) - sr := &StreamReader{ - src: readerSrc, - bandwidthRemaining: tt.bwLeft, - spaceRemaining: tt.spaceLeft, - hash: sha256.New(), - } - - outputBuf := make([]byte, tt.outputBufLen) - n, err := io.ReadFull(sr, outputBuf) - - if tt.eofErr { - assert.Error(t, err) - assert.True(t, err == io.ErrUnexpectedEOF) - assert.Equal(t, expectedHash, sr.hash.Sum(nil)) - } else if tt.bwErr { - assert.Error(t, err) - assert.True(t, StreamWriterError.Has(err)) - assert.Contains(t, err.Error(), "out of bandwidth") - } else if tt.spaceErr { - assert.Error(t, err) - assert.True(t, StreamWriterError.Has(err)) - assert.Contains(t, err.Error(), "out of space") - } else { - assert.NoError(t, err) - assert.Equal(t, expectedHash, sr.hash.Sum(nil)) - } - - assert.Equal(t, n, tt.n) - } -} diff --git a/pkg/piecestore/psserver/retrieve.go b/pkg/piecestore/psserver/retrieve.go deleted file mode 100644 index 7ede85212..000000000 --- a/pkg/piecestore/psserver/retrieve.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package psserver - -import ( - "context" - "fmt" - "io" - "sync/atomic" - - "github.com/zeebo/errs" - "go.uber.org/zap" - - "storj.io/storj/internal/memory" - "storj.io/storj/internal/sync2" - "storj.io/storj/pkg/pb" -) - -// RetrieveError is a type of error for failures in Server.Retrieve() -var RetrieveError = errs.Class("retrieve error") - -// Retrieve servers data from piecestore and sends to client -func (s *Server) Retrieve(stream pb.PieceStoreRoutes_RetrieveServer) (err error) { - ctx := stream.Context() - defer mon.Task()(&ctx)(&err) - - // Receive Signature - recv, err := stream.Recv() - if err != nil { - return RetrieveError.Wrap(err) - } - if recv == nil { - return RetrieveError.New("error receiving piece data") - } - - pd := recv.GetPieceData() - if pd == nil { - return RetrieveError.New("PieceStore message is nil") - } - - rba := recv.GetBandwidthAllocation() - if rba == nil { - return RetrieveError.New("Order message is nil") - } - - pba := rba.PayerAllocation - if pb.Equal(&pba, &pb.OrderLimit{}) { - return RetrieveError.New("OrderLimit message is empty") - } - - id, err := getNamespacedPieceID([]byte(pd.GetId()), pba.SatelliteId.Bytes()) - if err != nil { - return err - } - - s.log.Debug("Retrieving", - zap.String("Piece ID", id), - zap.Int64("Offset", pd.GetOffset()), - zap.Int64("Size", pd.GetPieceSize()), - ) - - // Get path to data being retrieved - fileSize, err := s.storage.Size(id) - if err != nil { - return err - } - - // Read the size specified - totalToRead := pd.GetPieceSize() - - // Read the entire file if specified -1 but make sure we do it from the correct offset - if pd.GetPieceSize() <= -1 || totalToRead+pd.GetOffset() > fileSize { - totalToRead = fileSize - pd.GetOffset() - } - - retrieved, allocated, err := s.retrieveData(ctx, stream, id, pd.GetOffset(), totalToRead) - if err != nil { - return err - } - - s.log.Info("Successfully retrieved", - zap.String("Piece ID", id), - zap.Int64("Allocated", allocated), - zap.Int64("Retrieved", retrieved), - ) - return nil -} - -func (s *Server) retrieveData(ctx context.Context, stream pb.PieceStoreRoutes_RetrieveServer, id string, offset, length int64) (retrieved, allocated int64, err error) { - defer mon.Task()(&ctx)(&err) - - storeFile, err := s.storage.Reader(ctx, id, offset, length) - if err != nil { - return 0, 0, RetrieveError.Wrap(err) - } - - defer func() { - err = errs.Combine(err, storeFile.Close()) - }() - - writer := NewStreamWriter(s, stream) - allocationTracking := sync2.NewThrottle() - totalAllocated := int64(0) - - // Bandwidth Allocation recv loop - go func() { - var lastTotal int64 - var lastAllocation *pb.Order - defer func() { - if lastAllocation == nil { - return - } - err := s.DB.WriteBandwidthAllocToDB(lastAllocation) - if err != nil { - // TODO: handle error properly - s.log.Error("WriteBandwidthAllocToDB Error:", zap.Error(err)) - } - }() - - for { - recv, err := stream.Recv() - if err != nil { - allocationTracking.Fail(RetrieveError.Wrap(err)) - return - } - rba := recv.BandwidthAllocation - if err = s.verifySignature(stream.Context(), rba); err != nil { - allocationTracking.Fail(RetrieveError.Wrap(err)) - return - } - pba := rba.PayerAllocation - if err = s.verifyPayerAllocation(&pba, "GET"); err != nil { - allocationTracking.Fail(RetrieveError.Wrap(err)) - return - } - //todo: figure out why this fails tests - // if rba.Total > pba.MaxSize { - // allocationTracking.Fail(fmt.Errorf("attempt to send more data than allocation %v got %v", rba.Total, pba.MaxSize)) - // return - // } - if lastTotal > rba.Total { - allocationTracking.Fail(fmt.Errorf("got lower allocation was %v got %v", lastTotal, rba.Total)) - return - } - atomic.StoreInt64(&totalAllocated, rba.Total) - if err = allocationTracking.Produce(rba.Total - lastTotal); err != nil { - return - } - - lastAllocation = rba - lastTotal = rba.Total - } - }() - - // Data send loop - messageSize := int64(32 * memory.KiB) - used := int64(0) - - for used < length { - nextMessageSize, err := allocationTracking.ConsumeOrWait(messageSize) - if err != nil { - allocationTracking.Fail(RetrieveError.Wrap(err)) - break - } - - toCopy := nextMessageSize - if length-used < nextMessageSize { - toCopy = length - used - } - - used += nextMessageSize - - n, err := io.CopyN(writer, storeFile, toCopy) - if err != nil { - // break on error - allocationTracking.Fail(RetrieveError.Wrap(err)) - break - } - // correct errors when needed - if n != nextMessageSize { - if err := allocationTracking.Produce(nextMessageSize - n); err != nil { - break - } - used -= nextMessageSize - n - } - } - - // TODO: handle errors - // _ = stream.Close() - - return used, atomic.LoadInt64(&totalAllocated), allocationTracking.Err() -} diff --git a/pkg/piecestore/psserver/server.go b/pkg/piecestore/psserver/server.go deleted file mode 100644 index 90679a26b..000000000 --- a/pkg/piecestore/psserver/server.go +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package psserver - -import ( - "context" - "crypto" - "crypto/hmac" - "crypto/sha512" - "errors" - "fmt" - "io" - "os" - "path/filepath" - "strings" - "time" - - "github.com/mr-tron/base58/base58" - "github.com/zeebo/errs" - "go.uber.org/zap" - - "storj.io/storj/pkg/auth" - "storj.io/storj/pkg/identity" - "storj.io/storj/pkg/kademlia" - "storj.io/storj/pkg/pb" - "storj.io/storj/pkg/peertls" - pstore "storj.io/storj/pkg/piecestore" - "storj.io/storj/pkg/piecestore/psserver/psdb" - "storj.io/storj/pkg/storj" -) - -var ( - // ServerError wraps errors returned from Server struct methods - ServerError = errs.Class("PSServer error") -) - -// DirSize returns the total size of the files in that directory -func DirSize(path string) (int64, error) { - var size int64 - _, err := os.Stat(path) - if err != nil { - return 0, errors.New("path doesn't exists") - } - adjSize := func(_ string, info os.FileInfo, err error) error { - if !info.IsDir() { - size += info.Size() - } - return err - } - err = filepath.Walk(path, adjSize) - - return size, err -} - -// Storage describes storing blobs on disk -type Storage interface { - // Writer returns a writer for the specified pieceID - Writer(pieceID string) (io.WriteCloser, error) - // Reader returns a reader for the specified pieceID - Reader(ctx context.Context, pieceID string, offset int64, length int64) (io.ReadCloser, error) - // Delete deletes the specified pieceID - Delete(pieceID string) error - - // Close closes the underlying database. - Close() error - - // Size returns size of the piece - Size(pieceID string) (int64, error) - // Info returns the current status of the disk. - Info() (pstore.DiskInfo, error) -} - -// Server implements serving and storing pieces -type Server struct { - startTime time.Time - log *zap.Logger - storage Storage - DB *psdb.DB - identity *identity.FullIdentity - totalAllocated int64 // TODO: use memory.Size - totalBwAllocated int64 // TODO: use memory.Size - whitelist map[storj.NodeID]crypto.PublicKey - kad *kademlia.Kademlia -} - -// NewEndpoint creates a new endpoint -func NewEndpoint(log *zap.Logger, config Config, storage Storage, db *psdb.DB, identity *identity.FullIdentity, k *kademlia.Kademlia) (*Server, error) { - // read the allocated disk space from the config file - allocatedDiskSpace := config.AllocatedDiskSpace.Int64() - allocatedBandwidth := config.AllocatedBandwidth.Int64() - - // get the disk space details - // The returned path ends in a slash only if it represents a root directory, such as "/" on Unix or `C:\` on Windows. - info, err := storage.Info() - if err != nil { - return nil, ServerError.Wrap(err) - } - freeDiskSpace := info.AvailableSpace - - // get how much is currently used, if for the first time totalUsed = 0 - totalUsed, err := db.SumTTLSizes() - if err != nil { - //first time setup - totalUsed = 0 - } - - usedBandwidth, err := db.GetTotalBandwidthBetween(getBeginningOfMonth(), time.Now()) - if err != nil { - return nil, ServerError.Wrap(err) - } - - if usedBandwidth > allocatedBandwidth { - log.Warn("Exceed the allowed Bandwidth setting") - } else { - log.Info("Remaining Bandwidth", zap.Int64("bytes", allocatedBandwidth-usedBandwidth)) - } - - // check your hard drive is big enough - // first time setup as a piece node server - if totalUsed == 0 && freeDiskSpace < allocatedDiskSpace { - allocatedDiskSpace = freeDiskSpace - log.Warn("Disk space is less than requested. Allocating space", zap.Int64("bytes", allocatedDiskSpace)) - } - - // on restarting the Piece node server, assuming already been working as a node - // used above the alloacated space, user changed the allocation space setting - // before restarting - if totalUsed >= allocatedDiskSpace { - log.Warn("Used more space than allocated. Allocating space", zap.Int64("bytes", allocatedDiskSpace)) - } - - // the available diskspace is less than remaining allocated space, - // due to change of setting before restarting - if freeDiskSpace < allocatedDiskSpace-totalUsed { - allocatedDiskSpace = freeDiskSpace - log.Warn("Disk space is less than requested. Allocating space", zap.Int64("bytes", allocatedDiskSpace)) - } - - // parse the comma separated list of approved satellite IDs into an array of storj.NodeIDs - whitelist := make(map[storj.NodeID]crypto.PublicKey) - if config.SatelliteIDRestriction { - idStrings := strings.Split(config.WhitelistedSatelliteIDs, ",") - for _, s := range idStrings { - if s == "" { - continue - } - satID, err := storj.NodeIDFromString(s) - if err != nil { - return nil, err - } - whitelist[satID] = nil // we will set these later - } - } - - return &Server{ - startTime: time.Now(), - log: log, - storage: storage, - DB: db, - identity: identity, - totalAllocated: allocatedDiskSpace, - totalBwAllocated: allocatedBandwidth, - whitelist: whitelist, - kad: k, - }, nil -} - -// Close stops the server -func (s *Server) Close() error { return nil } - -// Stop the piececstore node -func (s *Server) Stop(ctx context.Context) error { - return errs.Combine( - s.DB.Close(), - s.storage.Close(), - ) -} - -// Piece servers meta information about a piece. -func (s *Server) Piece(ctx context.Context, in *pb.PieceId) (*pb.PieceSummary, error) { - s.log.Debug("Getting Meta", zap.String("Piece ID", in.GetId())) - - id, err := getNamespacedPieceID([]byte(in.GetId()), in.SatelliteId.Bytes()) - if err != nil { - return nil, err - } - - size, err := s.storage.Size(id) - if err != nil { - return nil, err - } - - // Read database to calculate expiration - ttl, err := s.DB.GetTTLByID(id) - if err != nil { - return nil, err - } - - s.log.Info("Successfully retrieved meta", zap.String("Piece ID", in.GetId())) - return &pb.PieceSummary{Id: in.GetId(), PieceSize: size, ExpirationUnixSec: ttl}, nil -} - -// Delete deletes data based on the specified ID. -func (s *Server) Delete(ctx context.Context, in *pb.PieceDelete) (*pb.PieceDeleteSummary, error) { - s.log.Debug("Deleting", zap.String("Piece ID", fmt.Sprint(in.GetId()))) - - id, err := getNamespacedPieceID([]byte(in.GetId()), in.SatelliteId.Bytes()) - if err != nil { - return nil, err - } - if err := s.deleteByID(id); err != nil { - return nil, err - } - - s.log.Info("Successfully deleted", zap.String("Piece ID", fmt.Sprint(in.GetId()))) - - return &pb.PieceDeleteSummary{Message: OK}, nil -} - -func (s *Server) deleteByID(id string) error { - return errs.Combine( - s.DB.DeleteTTLByID(id), - s.storage.Delete(id), - ) -} - -func (s *Server) verifySignature(ctx context.Context, rba *pb.Order) error { - // TODO(security): detect replay attacks - pba := rba.PayerAllocation - //verify message content - pi, err := identity.PeerIdentityFromContext(ctx) - if err != nil || pba.UplinkId != pi.ID { - return auth.ErrBadID.New("Uplink Node ID: %s vs %s", pba.UplinkId, pi.ID) - } - - //todo: use whitelist for satellites? - switch { - case len(pba.SerialNumber) == 0: - return pb.ErrPayer.Wrap(auth.ErrMissing.New("serial")) - case pba.SatelliteId.IsZero(): - return pb.ErrPayer.Wrap(auth.ErrMissing.New("satellite id")) - case pba.UplinkId.IsZero(): - return pb.ErrPayer.Wrap(auth.ErrMissing.New("uplink id")) - } - exp := time.Unix(pba.GetExpirationUnixSec(), 0).UTC() - if exp.Before(time.Now().UTC()) { - return pb.ErrPayer.Wrap(auth.ErrExpired.New("%v vs %v", exp, time.Now().UTC())) - } - //verify message crypto - if err := auth.VerifyMsg(rba, pba.UplinkId); err != nil { - return pb.ErrRenter.Wrap(err) - } - if !s.isWhitelisted(pba.SatelliteId) { - return pb.ErrPayer.Wrap(peertls.ErrVerifyCAWhitelist.New("")) - } - //todo: once the certs are removed from the PBA, use s.whitelist to check satellite signatures - if err := auth.VerifyMsg(&pba, pba.SatelliteId); err != nil { - return pb.ErrPayer.Wrap(err) - } - return nil -} - -func (s *Server) verifyPayerAllocation(pba *pb.OrderLimit, actionPrefix string) (err error) { - switch { - case pba.SatelliteId.IsZero(): - return StoreError.New("payer bandwidth allocation: missing satellite id") - case pba.UplinkId.IsZero(): - return StoreError.New("payer bandwidth allocation: missing uplink id") - case !strings.HasPrefix(pba.Action.String(), actionPrefix): - return StoreError.New("payer bandwidth allocation: invalid action %v", pba.Action.String()) - } - return nil -} - -//isWhitelisted returns true if a node ID exists in a list of approved node IDs -func (s *Server) isWhitelisted(id storj.NodeID) bool { - if len(s.whitelist) == 0 { - return true // don't whitelist if the whitelist is empty - } - _, found := s.whitelist[id] - return found -} - -func (s *Server) getPublicKey(ctx context.Context, id storj.NodeID) (crypto.PublicKey, error) { - pID, err := s.kad.FetchPeerIdentity(ctx, id) - if err != nil { - return nil, err - } - return pID.Leaf.PublicKey, nil -} - -func getBeginningOfMonth() time.Time { - t := time.Now() - y, m, _ := t.Date() - return time.Date(y, m, 1, 0, 0, 0, 0, time.Now().Location()) -} - -func getNamespacedPieceID(pieceID, namespace []byte) (string, error) { - if namespace == nil { - return string(pieceID), nil - } - - mac := hmac.New(sha512.New, namespace) - _, err := mac.Write(pieceID) - if err != nil { - return "", err - } - h := mac.Sum(nil) - return base58.Encode(h), nil -} diff --git a/pkg/piecestore/psserver/store.go b/pkg/piecestore/psserver/store.go deleted file mode 100644 index db9f10c00..000000000 --- a/pkg/piecestore/psserver/store.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package psserver - -import ( - "context" - "fmt" - "io" - "time" - - "github.com/zeebo/errs" - "go.uber.org/zap" - - "storj.io/storj/pkg/auth" - "storj.io/storj/pkg/pb" -) - -// OK - Success! -const OK = "OK" - -// StoreError is a type of error for failures in Server.Store() -var StoreError = errs.Class("store error") - -// Store stores incoming data using piecestore -func (s *Server) Store(reqStream pb.PieceStoreRoutes_StoreServer) (err error) { - ctx := reqStream.Context() - defer mon.Task()(&ctx)(&err) - // Receive id/ttl - recv, err := reqStream.Recv() - if err != nil { - return StoreError.Wrap(err) - } - if recv == nil { - return StoreError.New("error receiving Piece metadata") - } - - pd := recv.GetPieceData() - if pd == nil { - return StoreError.New("PieceStore message is nil") - } - - s.log.Debug("Storing", zap.String("Piece ID", fmt.Sprint(pd.GetId()))) - - if pd.GetId() == "" { - return StoreError.New("piece ID not specified") - } - - rba := recv.GetBandwidthAllocation() - if rba == nil { - return StoreError.New("Order message is nil") - } - - pba := rba.PayerAllocation - if pb.Equal(&pba, &pb.OrderLimit{}) { - return StoreError.New("OrderLimit message is empty") - } - - id, err := getNamespacedPieceID([]byte(pd.GetId()), pba.SatelliteId.Bytes()) - if err != nil { - return err - } - total, hash, err := s.storeData(ctx, reqStream, id) - if err != nil { - return err - } - - if err = s.DB.AddTTL(id, pd.GetExpirationUnixSec(), total); err != nil { - deleteErr := s.deleteByID(id) - return StoreError.New("failed to write piece meta data to database: %v", errs.Combine(err, deleteErr)) - } - - signedHash := &pb.SignedHash{Hash: hash} - err = auth.SignMessage(signedHash, *s.identity) - if err != nil { - return err - } - - s.log.Info("Successfully stored", zap.String("Piece ID", fmt.Sprint(pd.GetId()))) - - return reqStream.SendAndClose(&pb.PieceStoreSummary{ - Message: OK, - TotalReceived: total, - SignedHash: signedHash, - }) -} - -func (s *Server) storeData(ctx context.Context, stream pb.PieceStoreRoutes_StoreServer, id string) (total int64, hash []byte, err error) { - defer mon.Task()(&ctx)(&err) - - // Delete data if we error - defer func() { - if err != nil && err != io.EOF { - if deleteErr := s.deleteByID(id); deleteErr != nil { - s.log.Error("Failed on deleteByID in Store", zap.Error(deleteErr)) - } - } - }() - - // Initialize file for storing data - storeFile, err := s.storage.Writer(id) - if err != nil { - return 0, nil, err - } - - defer func() { - err = errs.Combine(err, storeFile.Close()) - }() - - bwUsed, err := s.DB.GetTotalBandwidthBetween(getBeginningOfMonth(), time.Now()) - if err != nil { - return 0, nil, err - } - spaceUsed, err := s.DB.SumTTLSizes() - if err != nil { - return 0, nil, err - } - bwLeft := s.totalBwAllocated - bwUsed - spaceLeft := s.totalAllocated - spaceUsed - reader := NewStreamReader(s, stream, bwLeft, spaceLeft) - - total, err = io.Copy(storeFile, reader) - - if err != nil && err != io.EOF { - return 0, nil, err - } - - err = s.DB.WriteBandwidthAllocToDB(reader.bandwidthAllocation) - if err != nil { - return 0, nil, err - } - hash = reader.hash.Sum(nil) - return total, hash, nil -} diff --git a/pkg/piecestore/pstore.go b/pkg/piecestore/pstore.go deleted file mode 100644 index e28f052a2..000000000 --- a/pkg/piecestore/pstore.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package pstore - -import ( - "context" - "io" - "os" - "path/filepath" - - "github.com/shirou/gopsutil/disk" - "github.com/zeebo/errs" - - "storj.io/storj/pkg/ranger" -) - -// IDLength -- Minimum ID length -const IDLength = 20 - -// Errors -var ( - Error = errs.Class("piecestore error") -) - -// Storage stores piecestore pieces -type Storage struct { - dir string -} - -// NewStorage creates database for storing pieces -func NewStorage(dir string) *Storage { - return &Storage{dir} -} - -// Close closes resources -func (storage *Storage) Close() error { return nil } - -// DiskInfo contains statistics about the disk -type DiskInfo struct { - AvailableSpace int64 // TODO: use memory.Size -} - -// Info returns information about the current state of the dir -func (storage *Storage) Info() (DiskInfo, error) { - rootPath := filepath.Dir(filepath.Clean(storage.dir)) - diskSpace, err := disk.Usage(rootPath) - if err != nil { - return DiskInfo{}, Error.Wrap(err) - } - return DiskInfo{ - AvailableSpace: int64(diskSpace.Free), - }, nil -} - -// piecePath creates piece storage path from id and dir -func (storage *Storage) piecePath(pieceID string) (string, error) { - if len(pieceID) < IDLength { - return "", Error.New("invalid id length") - } - folder1, folder2, filename := pieceID[0:2], pieceID[2:4], pieceID[4:] - return filepath.Join(storage.dir, folder1, folder2, filename), nil -} - -// Size returns piece size. -func (storage *Storage) Size(pieceID string) (int64, error) { - path, err := storage.piecePath(pieceID) - if err != nil { - return 0, err - } - - fileInfo, err := os.Stat(path) - if err != nil { - return 0, Error.Wrap(err) - } - - return fileInfo.Size(), nil -} - -// Writer returns a writer that can be used to store piece. -func (storage *Storage) Writer(pieceID string) (io.WriteCloser, error) { - path, err := storage.piecePath(pieceID) - if err != nil { - return nil, err - } - if err = os.MkdirAll(filepath.Dir(path), 0700); err != nil { - return nil, Error.Wrap(err) - } - file, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0600) - if err != nil { - return nil, Error.Wrap(err) - } - return file, nil -} - -// Reader returns a reader for the specified piece at the location -func (storage *Storage) Reader(ctx context.Context, pieceID string, offset int64, length int64) (io.ReadCloser, error) { - path, err := storage.piecePath(pieceID) - if err != nil { - return nil, err - } - - info, err := os.Stat(path) - if err != nil { - return nil, err - } - - if offset >= info.Size() || offset < 0 { - return nil, Error.New("invalid offset: %v", offset) - } - if length <= -1 { - length = info.Size() - } - // If trying to read past the end of the file, just read to the end - if info.Size() < offset+length { - length = info.Size() - offset - } - - rr, err := ranger.FileRanger(path) - if err != nil { - return nil, Error.Wrap(err) - } - - r, err := rr.Range(ctx, offset, length) - return r, Error.Wrap(err) -} - -// Delete deletes piece from storage -func (storage *Storage) Delete(pieceID string) error { - path, err := storage.piecePath(pieceID) - if err != nil { - return Error.Wrap(err) - } - err = os.Remove(path) - if os.IsNotExist(err) { - err = nil - } - return Error.Wrap(err) -} diff --git a/pkg/utils/io.go b/pkg/utils/io.go deleted file mode 100644 index a607e664b..000000000 --- a/pkg/utils/io.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package utils - -// ReaderSource takes a src func and turns it into an io.Reader -type ReaderSource struct { - src func() ([]byte, error) - buf []byte - err error -} - -// NewReaderSource makes a new ReaderSource -func NewReaderSource(src func() ([]byte, error)) *ReaderSource { - return &ReaderSource{src: src} -} - -// Read implements io.Reader -func (rs *ReaderSource) Read(p []byte) (n int, err error) { - // TODO: bug, buffer should be fully read before returning an error - if rs.err != nil { - return 0, rs.err - } - if len(rs.buf) == 0 { - rs.buf, rs.err = rs.src() - } - - n = copy(p, rs.buf) - rs.buf = rs.buf[n:] - return n, rs.err -} diff --git a/pkg/utils/io_test.go b/pkg/utils/io_test.go deleted file mode 100644 index 79698fcdd..000000000 --- a/pkg/utils/io_test.go +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2019 Storj Labs, Inc. -// See LICENSE for copying information. - -package utils - -import ( - "io" - "testing" -) - -type testBytes [][]byte - -func (t *testBytes) Next() (rv []byte, err error) { - if len(*t) > 0 { - rv, *t = (*t)[0], (*t)[1:] - return rv, nil - } - return nil, io.EOF -} - -func TestReaderSource(t *testing.T) { - tb := testBytes([][]byte{ - []byte("hello there"), - []byte("cool"), - []byte("beans"), - }) - - rs := NewReaderSource(tb.Next) - - buf := make([]byte, 1) - n, err := rs.Read(buf) - if n != 1 || err != nil || string(buf) != "h" { - t.Fatalf("unexpected result: %d, %v", n, err) - } - - buf = make([]byte, 10) - n, err = rs.Read(buf) - if n != 10 || err != nil || string(buf) != "ello there" { - t.Fatalf("unexpected result: %d, %v", n, err) - } - - buf = make([]byte, 5) - n, err = rs.Read(buf) - if n != 4 || err != nil || string(buf[:4]) != "cool" { - t.Fatalf("unexpected result: %d, %v", n, err) - } - - n, err = rs.Read(buf) - if n != 5 || err != nil || string(buf[:5]) != "beans" { - t.Fatalf("unexpected result: %d, %v", n, err) - } - - n, err = rs.Read(buf) - if n != 0 || err != io.EOF { - t.Fatalf("unexpected result: %d, %v", n, err) - } -} - -type testBytesFastEOF [][]byte - -func (t *testBytesFastEOF) Next() (rv []byte, err error) { - if len(*t) > 0 { - rv, *t = (*t)[0], (*t)[1:] - if len(*t) == 0 { - return rv, io.EOF - } - return rv, nil - } - return nil, io.EOF -} - -func TestReaderSourceFastEOF(t *testing.T) { - tb := testBytesFastEOF([][]byte{ - []byte("hello there"), - []byte("cool"), - []byte("beans"), - }) - - rs := NewReaderSource(tb.Next) - - buf := make([]byte, 1) - n, err := rs.Read(buf) - if n != 1 || err != nil || string(buf) != "h" { - t.Fatalf("unexpected result: %d, %v", n, err) - } - - buf = make([]byte, 10) - n, err = rs.Read(buf) - if n != 10 || err != nil || string(buf) != "ello there" { - t.Fatalf("unexpected result: %d, %v", n, err) - } - - buf = make([]byte, 5) - n, err = rs.Read(buf) - if n != 4 || err != nil || string(buf[:4]) != "cool" { - t.Fatalf("unexpected result: %d, %v", n, err) - } - - n, err = rs.Read(buf) - if n != 5 || err != io.EOF || string(buf[:5]) != "beans" { - t.Fatalf("unexpected result: %d, %v", n, err) - } -} diff --git a/proto.lock b/proto.lock index fb2cfbd9b..e40d6bb8e 100644 --- a/proto.lock +++ b/proto.lock @@ -1165,8 +1165,8 @@ "name": "DumpNodes", "in_type": "DumpNodesRequest", "out_type": "DumpNodesResponse" - }, - { + }, + { "name": "GetStats", "in_type": "GetStatsRequest", "out_type": "GetStatsResponse" @@ -2470,244 +2470,6 @@ } ] }, - { - "name": "PieceStore", - "fields": [ - { - "id": 1, - "name": "bandwidth_allocation", - "type": "RenterBandwidthAllocation" - }, - { - "id": 2, - "name": "piece_data", - "type": "PieceData" - }, - { - "id": 3, - "name": "authorization", - "type": "SignedMessage", - "options": [ - { - "name": "deprecated", - "value": "true" - } - ] - }, - { - "id": 4, - "name": "signed_hash", - "type": "SignedHash" - } - ], - "messages": [ - { - "name": "PieceData", - "fields": [ - { - "id": 1, - "name": "id", - "type": "string" - }, - { - "id": 2, - "name": "expiration_unix_sec", - "type": "int64" - }, - { - "id": 3, - "name": "content", - "type": "bytes" - } - ] - } - ] - }, - { - "name": "PieceId", - "fields": [ - { - "id": 1, - "name": "id", - "type": "string" - }, - { - "id": 2, - "name": "authorization", - "type": "SignedMessage", - "options": [ - { - "name": "deprecated", - "value": "true" - } - ] - }, - { - "id": 3, - "name": "satellite_id", - "type": "bytes", - "options": [ - { - "name": "(gogoproto.customtype)", - "value": "NodeID" - }, - { - "name": "(gogoproto.nullable)", - "value": "false" - } - ] - } - ] - }, - { - "name": "PieceSummary", - "fields": [ - { - "id": 1, - "name": "id", - "type": "string" - }, - { - "id": 2, - "name": "piece_size", - "type": "int64" - }, - { - "id": 3, - "name": "expiration_unix_sec", - "type": "int64" - } - ] - }, - { - "name": "PieceRetrieval", - "fields": [ - { - "id": 1, - "name": "bandwidth_allocation", - "type": "RenterBandwidthAllocation" - }, - { - "id": 2, - "name": "piece_data", - "type": "PieceData" - }, - { - "id": 3, - "name": "authorization", - "type": "SignedMessage", - "options": [ - { - "name": "deprecated", - "value": "true" - } - ] - } - ], - "messages": [ - { - "name": "PieceData", - "fields": [ - { - "id": 1, - "name": "id", - "type": "string" - }, - { - "id": 2, - "name": "piece_size", - "type": "int64" - }, - { - "id": 3, - "name": "offset", - "type": "int64" - } - ] - } - ] - }, - { - "name": "PieceRetrievalStream", - "fields": [ - { - "id": 1, - "name": "piece_size", - "type": "int64" - }, - { - "id": 2, - "name": "content", - "type": "bytes" - } - ] - }, - { - "name": "PieceDelete", - "fields": [ - { - "id": 1, - "name": "id", - "type": "string" - }, - { - "id": 3, - "name": "authorization", - "type": "SignedMessage", - "options": [ - { - "name": "deprecated", - "value": "true" - } - ] - }, - { - "id": 4, - "name": "satellite_id", - "type": "bytes", - "options": [ - { - "name": "(gogoproto.customtype)", - "value": "NodeID" - }, - { - "name": "(gogoproto.nullable)", - "value": "false" - } - ] - } - ] - }, - { - "name": "PieceDeleteSummary", - "fields": [ - { - "id": 1, - "name": "message", - "type": "string" - } - ] - }, - { - "name": "PieceStoreSummary", - "fields": [ - { - "id": 1, - "name": "message", - "type": "string" - }, - { - "id": 2, - "name": "total_received", - "type": "int64" - }, - { - "id": 3, - "name": "signed_hash", - "type": "SignedHash" - } - ] - }, { "name": "SignedMessage", "fields": [ @@ -2750,36 +2512,6 @@ ] } ], - "services": [ - { - "name": "PieceStoreRoutes", - "rpcs": [ - { - "name": "Piece", - "in_type": "PieceId", - "out_type": "PieceSummary" - }, - { - "name": "Retrieve", - "in_type": "PieceRetrieval", - "out_type": "PieceRetrievalStream", - "in_streamed": true, - "out_streamed": true - }, - { - "name": "Store", - "in_type": "PieceStore", - "out_type": "PieceStoreSummary", - "in_streamed": true - }, - { - "name": "Delete", - "in_type": "PieceDelete", - "out_type": "PieceDeleteSummary" - } - ] - } - ], "imports": [ { "path": "gogo.proto" diff --git a/storagenode/peer.go b/storagenode/peer.go index 645d65061..a1b705c58 100644 --- a/storagenode/peer.go +++ b/storagenode/peer.go @@ -39,7 +39,6 @@ type DB interface { // Close closes the database Close() error - Storage() psserver.Storage Pieces() storage.Blobs Orders() orders.DB @@ -89,10 +88,6 @@ type Peer struct { Inspector *kademlia.Inspector } - Storage struct { - Endpoint *psserver.Server // TODO: separate into endpoint and service - } - Agreements struct { Sender *agreementsender.AgreementSender } @@ -171,18 +166,6 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config Config) (*P pb.RegisterKadInspectorServer(peer.Server.PrivateGRPC(), peer.Kademlia.Inspector) } - { // setup piecestore - // TODO: move this setup logic into psstore package - config := config.Storage - - // TODO: psserver shouldn't need the private key - peer.Storage.Endpoint, err = psserver.NewEndpoint(peer.Log.Named("piecestore"), config, peer.DB.Storage(), peer.DB.PSDB(), peer.Identity, peer.Kademlia.Service) - if err != nil { - return nil, errs.Combine(err, peer.Close()) - } - pb.RegisterPieceStoreRoutesServer(peer.Server.GRPC(), peer.Storage.Endpoint) - } - { // agreements config := config.Storage // TODO: separate config peer.Agreements.Sender = agreementsender.New( @@ -301,9 +284,6 @@ func (peer *Peer) Close() error { } // close services in reverse initialization order - if peer.Storage.Endpoint != nil { - errlist.Add(peer.Storage.Endpoint.Close()) - } if peer.Kademlia.Service != nil { errlist.Add(peer.Kademlia.Service.Close()) } diff --git a/storagenode/storagenodedb/database.go b/storagenode/storagenodedb/database.go index 3ef1e845d..4371c7014 100644 --- a/storagenode/storagenodedb/database.go +++ b/storagenode/storagenodedb/database.go @@ -8,8 +8,6 @@ import ( "go.uber.org/zap" "storj.io/storj/pkg/kademlia" - pstore "storj.io/storj/pkg/piecestore" - "storj.io/storj/pkg/piecestore/psserver" "storj.io/storj/pkg/piecestore/psserver/psdb" "storj.io/storj/storage" "storj.io/storj/storage/boltdb" @@ -33,9 +31,8 @@ type Config struct { // DB contains access to different database tables type DB struct { - log *zap.Logger - storage psserver.Storage - psdb *psdb.DB + log *zap.Logger + psdb *psdb.DB pieces interface { storage.Blobs @@ -49,8 +46,6 @@ type DB struct { // New creates a new master database for storage node func New(log *zap.Logger, config Config) (*DB, error) { - storage := pstore.NewStorage(config.Storage) - piecesDir, err := filestore.NewDir(config.Pieces) if err != nil { return nil, err @@ -73,9 +68,8 @@ func New(log *zap.Logger, config Config) (*DB, error) { } return &DB{ - log: log, - storage: storage, - psdb: psdb, + log: log, + psdb: psdb, pieces: pieces, @@ -89,8 +83,6 @@ func New(log *zap.Logger, config Config) (*DB, error) { // NewInMemory creates new inmemory master database for storage node // TODO: still stores data on disk func NewInMemory(log *zap.Logger, storageDir string) (*DB, error) { - storage := pstore.NewStorage(storageDir) - piecesDir, err := filestore.NewDir(storageDir) if err != nil { return nil, err @@ -108,9 +100,8 @@ func NewInMemory(log *zap.Logger, storageDir string) (*DB, error) { } return &DB{ - log: log, - storage: storage, - psdb: psdb, + log: log, + psdb: psdb, pieces: pieces, @@ -139,16 +130,9 @@ func (db *DB) Close() error { db.pieces.Close(), db.info.Close(), - - db.storage.Close(), ) } -// Storage returns piecestore location -func (db *DB) Storage() psserver.Storage { - return db.storage -} - // Pieces returns blob storage for pieces func (db *DB) Pieces() storage.Blobs { return db.pieces