Remove pointerdb.Server (#1609)
This commit is contained in:
parent
3b12b5e85c
commit
872bd5d7c1
@ -146,7 +146,7 @@ func (uplink *Uplink) DialPiecestore(ctx context.Context, destination Peer) (*pi
|
||||
|
||||
// Upload data to specific satellite
|
||||
func (uplink *Uplink) Upload(ctx context.Context, satellite *satellite.Peer, bucket string, path storj.Path, data []byte) error {
|
||||
config := uplink.getConfig(satellite)
|
||||
config := uplink.GetConfig(satellite)
|
||||
metainfo, streams, err := config.GetMetainfo(ctx, uplink.Identity)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -188,7 +188,7 @@ func (uplink *Uplink) Upload(ctx context.Context, satellite *satellite.Peer, buc
|
||||
|
||||
// UploadWithConfig uploads data to specific satellite with configured values
|
||||
func (uplink *Uplink) UploadWithConfig(ctx context.Context, satellite *satellite.Peer, redundancy *uplink.RSConfig, bucket string, path storj.Path, data []byte) error {
|
||||
config := uplink.getConfig(satellite)
|
||||
config := uplink.GetConfig(satellite)
|
||||
if redundancy != nil {
|
||||
config.RS.MinThreshold = redundancy.MinThreshold
|
||||
config.RS.RepairThreshold = redundancy.RepairThreshold
|
||||
@ -250,7 +250,7 @@ func uploadStream(ctx context.Context, streams streams.Store, mutableObject stor
|
||||
|
||||
// DownloadStream returns stream for downloading data.
|
||||
func (uplink *Uplink) DownloadStream(ctx context.Context, satellite *satellite.Peer, bucket string, path storj.Path) (*stream.Download, error) {
|
||||
config := uplink.getConfig(satellite)
|
||||
config := uplink.GetConfig(satellite)
|
||||
metainfo, streams, err := config.GetMetainfo(ctx, uplink.Identity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -281,7 +281,7 @@ func (uplink *Uplink) Download(ctx context.Context, satellite *satellite.Peer, b
|
||||
|
||||
// Delete data to specific satellite
|
||||
func (uplink *Uplink) Delete(ctx context.Context, satellite *satellite.Peer, bucket string, path storj.Path) error {
|
||||
config := uplink.getConfig(satellite)
|
||||
config := uplink.GetConfig(satellite)
|
||||
metainfo, _, err := config.GetMetainfo(ctx, uplink.Identity)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -289,7 +289,8 @@ func (uplink *Uplink) Delete(ctx context.Context, satellite *satellite.Peer, buc
|
||||
return metainfo.DeleteObject(ctx, bucket, path)
|
||||
}
|
||||
|
||||
func (uplink *Uplink) getConfig(satellite *satellite.Peer) uplink.Config {
|
||||
// GetConfig returns a default config for a given satellite.
|
||||
func (uplink *Uplink) GetConfig(satellite *satellite.Peer) uplink.Config {
|
||||
config := getDefaultConfig()
|
||||
config.Client.SatelliteAddr = satellite.Addr()
|
||||
config.Client.APIKey = uplink.APIKey[satellite.ID()]
|
||||
|
@ -115,35 +115,6 @@ func TestAuditSegment(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func makePutRequest(path storj.Path, expiration *timestamp.Timestamp) pb.PutRequest {
|
||||
var rps []*pb.RemotePiece
|
||||
rps = append(rps, &pb.RemotePiece{
|
||||
PieceNum: 1,
|
||||
NodeId: teststorj.NodeIDFromString("testId"),
|
||||
})
|
||||
pr := pb.PutRequest{
|
||||
Path: path,
|
||||
Pointer: &pb.Pointer{
|
||||
ExpirationDate: expiration,
|
||||
Type: pb.Pointer_REMOTE,
|
||||
Remote: &pb.RemoteSegment{
|
||||
Redundancy: &pb.RedundancyScheme{
|
||||
Type: pb.RedundancyScheme_RS,
|
||||
MinReq: 1,
|
||||
Total: 3,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 3,
|
||||
ErasureShareSize: 2,
|
||||
},
|
||||
RootPieceId: teststorj.PieceIDFromString("testId"),
|
||||
RemotePieces: rps,
|
||||
},
|
||||
SegmentSize: int64(10),
|
||||
},
|
||||
}
|
||||
return pr
|
||||
}
|
||||
|
||||
func TestDeleteExpired(t *testing.T) {
|
||||
testplanet.Run(t, testplanet.Config{
|
||||
SatelliteCount: 1, StorageNodeCount: 4, UplinkCount: 1,
|
||||
@ -196,10 +167,35 @@ func populateTestData(t *testing.T, planet *testplanet.Planet, expiration *times
|
||||
t.Run("putToDB", func(t *testing.T) {
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.bm, func(t *testing.T) {
|
||||
putRequest := makePutRequest(tt.path, expiration)
|
||||
require.NoError(t, pointerdb.Put(tt.path, putRequest.Pointer))
|
||||
pointer := makePointer(tt.path, expiration)
|
||||
require.NoError(t, pointerdb.Put(tt.path, pointer))
|
||||
})
|
||||
}
|
||||
})
|
||||
return tests, cursor, pointerdb
|
||||
}
|
||||
|
||||
func makePointer(path storj.Path, expiration *timestamp.Timestamp) *pb.Pointer {
|
||||
var rps []*pb.RemotePiece
|
||||
rps = append(rps, &pb.RemotePiece{
|
||||
PieceNum: 1,
|
||||
NodeId: teststorj.NodeIDFromString("testId"),
|
||||
})
|
||||
return &pb.Pointer{
|
||||
ExpirationDate: expiration,
|
||||
Type: pb.Pointer_REMOTE,
|
||||
Remote: &pb.RemoteSegment{
|
||||
Redundancy: &pb.RedundancyScheme{
|
||||
Type: pb.RedundancyScheme_RS,
|
||||
MinReq: 1,
|
||||
Total: 3,
|
||||
RepairThreshold: 2,
|
||||
SuccessThreshold: 3,
|
||||
ErasureShareSize: 2,
|
||||
},
|
||||
RootPieceId: teststorj.PieceIDFromString("testId"),
|
||||
RemotePieces: rps,
|
||||
},
|
||||
SegmentSize: int64(10),
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ type Service struct {
|
||||
|
||||
// NewService instantiates a Service with access to a Cursor and Verifier
|
||||
func NewService(log *zap.Logger, config Config, pointerdb *pointerdb.Service,
|
||||
allocation *pointerdb.AllocationSigner, orders *orders.Service, transport transport.Client, overlay *overlay.Cache,
|
||||
orders *orders.Service, transport transport.Client, overlay *overlay.Cache,
|
||||
identity *identity.FullIdentity) (service *Service, err error) {
|
||||
return &Service{
|
||||
log: log,
|
||||
|
@ -4,12 +4,10 @@
|
||||
package pb
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
timestamp "github.com/golang/protobuf/ptypes/timestamp"
|
||||
grpc "google.golang.org/grpc"
|
||||
math "math"
|
||||
)
|
||||
|
||||
@ -338,265 +336,6 @@ func (m *Pointer) GetMetadata() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
// PutRequest is a request message for the Put rpc call
|
||||
type PutRequest struct {
|
||||
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
|
||||
Pointer *Pointer `protobuf:"bytes,2,opt,name=pointer,proto3" json:"pointer,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PutRequest) Reset() { *m = PutRequest{} }
|
||||
func (m *PutRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*PutRequest) ProtoMessage() {}
|
||||
func (*PutRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{4}
|
||||
}
|
||||
func (m *PutRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PutRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PutRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PutRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *PutRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PutRequest.Merge(m, src)
|
||||
}
|
||||
func (m *PutRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_PutRequest.Size(m)
|
||||
}
|
||||
func (m *PutRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PutRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PutRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *PutRequest) GetPath() string {
|
||||
if m != nil {
|
||||
return m.Path
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *PutRequest) GetPointer() *Pointer {
|
||||
if m != nil {
|
||||
return m.Pointer
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetRequest is a request message for the Get rpc call
|
||||
type GetRequest struct {
|
||||
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetRequest) Reset() { *m = GetRequest{} }
|
||||
func (m *GetRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetRequest) ProtoMessage() {}
|
||||
func (*GetRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{5}
|
||||
}
|
||||
func (m *GetRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *GetRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetRequest.Merge(m, src)
|
||||
}
|
||||
func (m *GetRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_GetRequest.Size(m)
|
||||
}
|
||||
func (m *GetRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *GetRequest) GetPath() string {
|
||||
if m != nil {
|
||||
return m.Path
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ListRequest is a request message for the List rpc call
|
||||
type ListRequest struct {
|
||||
Prefix string `protobuf:"bytes,1,opt,name=prefix,proto3" json:"prefix,omitempty"`
|
||||
StartAfter string `protobuf:"bytes,2,opt,name=start_after,json=startAfter,proto3" json:"start_after,omitempty"`
|
||||
EndBefore string `protobuf:"bytes,3,opt,name=end_before,json=endBefore,proto3" json:"end_before,omitempty"`
|
||||
Recursive bool `protobuf:"varint,4,opt,name=recursive,proto3" json:"recursive,omitempty"`
|
||||
Limit int32 `protobuf:"varint,5,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||
MetaFlags uint32 `protobuf:"fixed32,6,opt,name=meta_flags,json=metaFlags,proto3" json:"meta_flags,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *ListRequest) Reset() { *m = ListRequest{} }
|
||||
func (m *ListRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*ListRequest) ProtoMessage() {}
|
||||
func (*ListRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{6}
|
||||
}
|
||||
func (m *ListRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ListRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *ListRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_ListRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *ListRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ListRequest.Merge(m, src)
|
||||
}
|
||||
func (m *ListRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_ListRequest.Size(m)
|
||||
}
|
||||
func (m *ListRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ListRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ListRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *ListRequest) GetPrefix() string {
|
||||
if m != nil {
|
||||
return m.Prefix
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *ListRequest) GetStartAfter() string {
|
||||
if m != nil {
|
||||
return m.StartAfter
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *ListRequest) GetEndBefore() string {
|
||||
if m != nil {
|
||||
return m.EndBefore
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *ListRequest) GetRecursive() bool {
|
||||
if m != nil {
|
||||
return m.Recursive
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *ListRequest) GetLimit() int32 {
|
||||
if m != nil {
|
||||
return m.Limit
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *ListRequest) GetMetaFlags() uint32 {
|
||||
if m != nil {
|
||||
return m.MetaFlags
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// PutResponse is a response message for the Put rpc call
|
||||
type PutResponse struct {
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PutResponse) Reset() { *m = PutResponse{} }
|
||||
func (m *PutResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*PutResponse) ProtoMessage() {}
|
||||
func (*PutResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{7}
|
||||
}
|
||||
func (m *PutResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PutResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PutResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PutResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *PutResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PutResponse.Merge(m, src)
|
||||
}
|
||||
func (m *PutResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_PutResponse.Size(m)
|
||||
}
|
||||
func (m *PutResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PutResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PutResponse proto.InternalMessageInfo
|
||||
|
||||
// GetResponse is a response message for the Get rpc call
|
||||
type GetResponse struct {
|
||||
Pointer *Pointer `protobuf:"bytes,1,opt,name=pointer,proto3" json:"pointer,omitempty"`
|
||||
Nodes []*Node `protobuf:"bytes,2,rep,name=nodes,proto3" json:"nodes,omitempty"`
|
||||
Pba *PayerBandwidthAllocation `protobuf:"bytes,3,opt,name=pba,proto3" json:"pba,omitempty"`
|
||||
Authorization *SignedMessage `protobuf:"bytes,4,opt,name=authorization,proto3" json:"authorization,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *GetResponse) Reset() { *m = GetResponse{} }
|
||||
func (m *GetResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*GetResponse) ProtoMessage() {}
|
||||
func (*GetResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{8}
|
||||
}
|
||||
func (m *GetResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_GetResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *GetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_GetResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *GetResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GetResponse.Merge(m, src)
|
||||
}
|
||||
func (m *GetResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_GetResponse.Size(m)
|
||||
}
|
||||
func (m *GetResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GetResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GetResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *GetResponse) GetPointer() *Pointer {
|
||||
if m != nil {
|
||||
return m.Pointer
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetResponse) GetNodes() []*Node {
|
||||
if m != nil {
|
||||
return m.Nodes
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetResponse) GetPba() *PayerBandwidthAllocation {
|
||||
if m != nil {
|
||||
return m.Pba
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetResponse) GetAuthorization() *SignedMessage {
|
||||
if m != nil {
|
||||
return m.Authorization
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ListResponse is a response message for the List rpc call
|
||||
type ListResponse struct {
|
||||
Items []*ListResponse_Item `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"`
|
||||
@ -610,7 +349,7 @@ func (m *ListResponse) Reset() { *m = ListResponse{} }
|
||||
func (m *ListResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*ListResponse) ProtoMessage() {}
|
||||
func (*ListResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{9}
|
||||
return fileDescriptor_75fef806d28fc810, []int{4}
|
||||
}
|
||||
func (m *ListResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ListResponse.Unmarshal(m, b)
|
||||
@ -657,7 +396,7 @@ func (m *ListResponse_Item) Reset() { *m = ListResponse_Item{} }
|
||||
func (m *ListResponse_Item) String() string { return proto.CompactTextString(m) }
|
||||
func (*ListResponse_Item) ProtoMessage() {}
|
||||
func (*ListResponse_Item) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{9, 0}
|
||||
return fileDescriptor_75fef806d28fc810, []int{4, 0}
|
||||
}
|
||||
func (m *ListResponse_Item) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_ListResponse_Item.Unmarshal(m, b)
|
||||
@ -698,214 +437,6 @@ func (m *ListResponse_Item) GetIsPrefix() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DeleteRequest) Reset() { *m = DeleteRequest{} }
|
||||
func (m *DeleteRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteRequest) ProtoMessage() {}
|
||||
func (*DeleteRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{10}
|
||||
}
|
||||
func (m *DeleteRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DeleteRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DeleteRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *DeleteRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DeleteRequest.Merge(m, src)
|
||||
}
|
||||
func (m *DeleteRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_DeleteRequest.Size(m)
|
||||
}
|
||||
func (m *DeleteRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DeleteRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *DeleteRequest) GetPath() string {
|
||||
if m != nil {
|
||||
return m.Path
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// DeleteResponse is a response message for the Delete rpc call
|
||||
type DeleteResponse struct {
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *DeleteResponse) Reset() { *m = DeleteResponse{} }
|
||||
func (m *DeleteResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*DeleteResponse) ProtoMessage() {}
|
||||
func (*DeleteResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{11}
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_DeleteResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_DeleteResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_DeleteResponse.Merge(m, src)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_DeleteResponse.Size(m)
|
||||
}
|
||||
func (m *DeleteResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_DeleteResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo
|
||||
|
||||
// IterateRequest is a request message for the Iterate rpc call
|
||||
type IterateRequest struct {
|
||||
Prefix string `protobuf:"bytes,1,opt,name=prefix,proto3" json:"prefix,omitempty"`
|
||||
First string `protobuf:"bytes,2,opt,name=first,proto3" json:"first,omitempty"`
|
||||
Recurse bool `protobuf:"varint,3,opt,name=recurse,proto3" json:"recurse,omitempty"`
|
||||
Reverse bool `protobuf:"varint,4,opt,name=reverse,proto3" json:"reverse,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *IterateRequest) Reset() { *m = IterateRequest{} }
|
||||
func (m *IterateRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*IterateRequest) ProtoMessage() {}
|
||||
func (*IterateRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{12}
|
||||
}
|
||||
func (m *IterateRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_IterateRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *IterateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_IterateRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *IterateRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_IterateRequest.Merge(m, src)
|
||||
}
|
||||
func (m *IterateRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_IterateRequest.Size(m)
|
||||
}
|
||||
func (m *IterateRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_IterateRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_IterateRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *IterateRequest) GetPrefix() string {
|
||||
if m != nil {
|
||||
return m.Prefix
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *IterateRequest) GetFirst() string {
|
||||
if m != nil {
|
||||
return m.First
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *IterateRequest) GetRecurse() bool {
|
||||
if m != nil {
|
||||
return m.Recurse
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (m *IterateRequest) GetReverse() bool {
|
||||
if m != nil {
|
||||
return m.Reverse
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type PayerBandwidthAllocationRequest struct {
|
||||
Action BandwidthAction `protobuf:"varint,1,opt,name=action,proto3,enum=piecestoreroutes.BandwidthAction" json:"action,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PayerBandwidthAllocationRequest) Reset() { *m = PayerBandwidthAllocationRequest{} }
|
||||
func (m *PayerBandwidthAllocationRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*PayerBandwidthAllocationRequest) ProtoMessage() {}
|
||||
func (*PayerBandwidthAllocationRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{13}
|
||||
}
|
||||
func (m *PayerBandwidthAllocationRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PayerBandwidthAllocationRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PayerBandwidthAllocationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PayerBandwidthAllocationRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *PayerBandwidthAllocationRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PayerBandwidthAllocationRequest.Merge(m, src)
|
||||
}
|
||||
func (m *PayerBandwidthAllocationRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_PayerBandwidthAllocationRequest.Size(m)
|
||||
}
|
||||
func (m *PayerBandwidthAllocationRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PayerBandwidthAllocationRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PayerBandwidthAllocationRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *PayerBandwidthAllocationRequest) GetAction() BandwidthAction {
|
||||
if m != nil {
|
||||
return m.Action
|
||||
}
|
||||
return BandwidthAction_PUT
|
||||
}
|
||||
|
||||
type PayerBandwidthAllocationResponse struct {
|
||||
Pba *PayerBandwidthAllocation `protobuf:"bytes,1,opt,name=pba,proto3" json:"pba,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *PayerBandwidthAllocationResponse) Reset() { *m = PayerBandwidthAllocationResponse{} }
|
||||
func (m *PayerBandwidthAllocationResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*PayerBandwidthAllocationResponse) ProtoMessage() {}
|
||||
func (*PayerBandwidthAllocationResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_75fef806d28fc810, []int{14}
|
||||
}
|
||||
func (m *PayerBandwidthAllocationResponse) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PayerBandwidthAllocationResponse.Unmarshal(m, b)
|
||||
}
|
||||
func (m *PayerBandwidthAllocationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_PayerBandwidthAllocationResponse.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *PayerBandwidthAllocationResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PayerBandwidthAllocationResponse.Merge(m, src)
|
||||
}
|
||||
func (m *PayerBandwidthAllocationResponse) XXX_Size() int {
|
||||
return xxx_messageInfo_PayerBandwidthAllocationResponse.Size(m)
|
||||
}
|
||||
func (m *PayerBandwidthAllocationResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PayerBandwidthAllocationResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PayerBandwidthAllocationResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *PayerBandwidthAllocationResponse) GetPba() *PayerBandwidthAllocation {
|
||||
if m != nil {
|
||||
return m.Pba
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("pointerdb.RedundancyScheme_SchemeType", RedundancyScheme_SchemeType_name, RedundancyScheme_SchemeType_value)
|
||||
proto.RegisterEnum("pointerdb.Pointer_DataType", Pointer_DataType_name, Pointer_DataType_value)
|
||||
@ -913,307 +444,57 @@ func init() {
|
||||
proto.RegisterType((*RemotePiece)(nil), "pointerdb.RemotePiece")
|
||||
proto.RegisterType((*RemoteSegment)(nil), "pointerdb.RemoteSegment")
|
||||
proto.RegisterType((*Pointer)(nil), "pointerdb.Pointer")
|
||||
proto.RegisterType((*PutRequest)(nil), "pointerdb.PutRequest")
|
||||
proto.RegisterType((*GetRequest)(nil), "pointerdb.GetRequest")
|
||||
proto.RegisterType((*ListRequest)(nil), "pointerdb.ListRequest")
|
||||
proto.RegisterType((*PutResponse)(nil), "pointerdb.PutResponse")
|
||||
proto.RegisterType((*GetResponse)(nil), "pointerdb.GetResponse")
|
||||
proto.RegisterType((*ListResponse)(nil), "pointerdb.ListResponse")
|
||||
proto.RegisterType((*ListResponse_Item)(nil), "pointerdb.ListResponse.Item")
|
||||
proto.RegisterType((*DeleteRequest)(nil), "pointerdb.DeleteRequest")
|
||||
proto.RegisterType((*DeleteResponse)(nil), "pointerdb.DeleteResponse")
|
||||
proto.RegisterType((*IterateRequest)(nil), "pointerdb.IterateRequest")
|
||||
proto.RegisterType((*PayerBandwidthAllocationRequest)(nil), "pointerdb.PayerBandwidthAllocationRequest")
|
||||
proto.RegisterType((*PayerBandwidthAllocationResponse)(nil), "pointerdb.PayerBandwidthAllocationResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("pointerdb.proto", fileDescriptor_75fef806d28fc810) }
|
||||
|
||||
var fileDescriptor_75fef806d28fc810 = []byte{
|
||||
// 1129 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x6f, 0x6f, 0x1b, 0xc5,
|
||||
0x13, 0xae, 0xff, 0xc7, 0x73, 0x76, 0xe2, 0xae, 0xfa, 0x4b, 0xfd, 0x73, 0x8b, 0x92, 0x1e, 0x2a,
|
||||
0x94, 0xb6, 0x72, 0x91, 0x5b, 0x09, 0x41, 0x41, 0xa8, 0x21, 0xa1, 0x58, 0x6a, 0x43, 0xb4, 0xc9,
|
||||
0x2b, 0x84, 0x74, 0x6c, 0x7c, 0x13, 0x7b, 0x85, 0xef, 0xf6, 0xba, 0xbb, 0x57, 0x9a, 0x7c, 0x13,
|
||||
0xbe, 0x09, 0x6f, 0x78, 0xcf, 0x67, 0xe0, 0x45, 0x91, 0x10, 0x1f, 0x83, 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0x00, 0x00, 0xff,
|
||||
0xff, 0x02, 0xf8, 0xe5, 0x03, 0x2f, 0x0a, 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
|
||||
|
||||
// PointerDBClient is the client API for PointerDB service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type PointerDBClient interface {
|
||||
// Put formats and hands off a file path to be saved to boltdb
|
||||
Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error)
|
||||
// Get formats and hands off a file path to get a small value from boltdb
|
||||
Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error)
|
||||
// List calls the bolt client's List function and returns all file paths
|
||||
List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error)
|
||||
// Delete formats and hands off a file path to delete from boltdb
|
||||
Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error)
|
||||
// PayerBandwidthAllocation returns signed payer bandwidth allocation struct
|
||||
PayerBandwidthAllocation(ctx context.Context, in *PayerBandwidthAllocationRequest, opts ...grpc.CallOption) (*PayerBandwidthAllocationResponse, error)
|
||||
}
|
||||
|
||||
type pointerDBClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewPointerDBClient(cc *grpc.ClientConn) PointerDBClient {
|
||||
return &pointerDBClient{cc}
|
||||
}
|
||||
|
||||
func (c *pointerDBClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*PutResponse, error) {
|
||||
out := new(PutResponse)
|
||||
err := c.cc.Invoke(ctx, "/pointerdb.PointerDB/Put", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *pointerDBClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) {
|
||||
out := new(GetResponse)
|
||||
err := c.cc.Invoke(ctx, "/pointerdb.PointerDB/Get", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *pointerDBClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) {
|
||||
out := new(ListResponse)
|
||||
err := c.cc.Invoke(ctx, "/pointerdb.PointerDB/List", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *pointerDBClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) {
|
||||
out := new(DeleteResponse)
|
||||
err := c.cc.Invoke(ctx, "/pointerdb.PointerDB/Delete", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *pointerDBClient) PayerBandwidthAllocation(ctx context.Context, in *PayerBandwidthAllocationRequest, opts ...grpc.CallOption) (*PayerBandwidthAllocationResponse, error) {
|
||||
out := new(PayerBandwidthAllocationResponse)
|
||||
err := c.cc.Invoke(ctx, "/pointerdb.PointerDB/PayerBandwidthAllocation", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// PointerDBServer is the server API for PointerDB service.
|
||||
type PointerDBServer interface {
|
||||
// Put formats and hands off a file path to be saved to boltdb
|
||||
Put(context.Context, *PutRequest) (*PutResponse, error)
|
||||
// Get formats and hands off a file path to get a small value from boltdb
|
||||
Get(context.Context, *GetRequest) (*GetResponse, error)
|
||||
// List calls the bolt client's List function and returns all file paths
|
||||
List(context.Context, *ListRequest) (*ListResponse, error)
|
||||
// Delete formats and hands off a file path to delete from boltdb
|
||||
Delete(context.Context, *DeleteRequest) (*DeleteResponse, error)
|
||||
// PayerBandwidthAllocation returns signed payer bandwidth allocation struct
|
||||
PayerBandwidthAllocation(context.Context, *PayerBandwidthAllocationRequest) (*PayerBandwidthAllocationResponse, error)
|
||||
}
|
||||
|
||||
func RegisterPointerDBServer(s *grpc.Server, srv PointerDBServer) {
|
||||
s.RegisterService(&_PointerDB_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _PointerDB_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PutRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PointerDBServer).Put(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pointerdb.PointerDB/Put",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PointerDBServer).Put(ctx, req.(*PutRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PointerDB_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PointerDBServer).Get(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pointerdb.PointerDB/Get",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PointerDBServer).Get(ctx, req.(*GetRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PointerDB_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PointerDBServer).List(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pointerdb.PointerDB/List",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PointerDBServer).List(ctx, req.(*ListRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PointerDB_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PointerDBServer).Delete(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pointerdb.PointerDB/Delete",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PointerDBServer).Delete(ctx, req.(*DeleteRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _PointerDB_PayerBandwidthAllocation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(PayerBandwidthAllocationRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(PointerDBServer).PayerBandwidthAllocation(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/pointerdb.PointerDB/PayerBandwidthAllocation",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(PointerDBServer).PayerBandwidthAllocation(ctx, req.(*PayerBandwidthAllocationRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _PointerDB_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "pointerdb.PointerDB",
|
||||
HandlerType: (*PointerDBServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Put",
|
||||
Handler: _PointerDB_Put_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Get",
|
||||
Handler: _PointerDB_Get_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "List",
|
||||
Handler: _PointerDB_List_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Delete",
|
||||
Handler: _PointerDB_Delete_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PayerBandwidthAllocation",
|
||||
Handler: _PointerDB_PayerBandwidthAllocation_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "pointerdb.proto",
|
||||
// 720 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xcd, 0x6e, 0xeb, 0x44,
|
||||
0x14, 0x6e, 0xfe, 0x9c, 0xf4, 0xd8, 0xf9, 0xb9, 0xa3, 0x2b, 0xb0, 0x72, 0x91, 0x52, 0x2c, 0x5d,
|
||||
0x28, 0xe2, 0xca, 0x45, 0xbe, 0x3b, 0xba, 0x40, 0x2a, 0xa9, 0x44, 0xa4, 0x12, 0xaa, 0x49, 0x56,
|
||||
0x6c, 0xac, 0x49, 0x7c, 0x1a, 0x8f, 0x88, 0x3d, 0xee, 0xcc, 0x44, 0x6a, 0xfb, 0x26, 0x3c, 0x0c,
|
||||
0x7b, 0x9e, 0x81, 0x45, 0x79, 0x11, 0x16, 0xc8, 0x33, 0x76, 0x92, 0x52, 0x89, 0xbb, 0xb1, 0xcf,
|
||||
0xcf, 0x77, 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, 0x7f, 0xfe, 0x65, 0x79, 0x3d,
|
||||
0x6a, 0x04, 0x7f, 0x34, 0xc0, 0xbb, 0xe1, 0x4a, 0x53, 0x54, 0x85, 0xc8, 0x15, 0x92, 0x08, 0x3a,
|
||||
0x5c, 0x63, 0xa6, 0xfc, 0x86, 0xd9, 0xf2, 0x17, 0x47, 0x54, 0x1d, 0xe3, 0xc2, 0x99, 0xc6, 0x8c,
|
||||
0x5a, 0x28, 0x21, 0xd0, 0xce, 0x84, 0x44, 0x73, 0x4d, 0x3d, 0x6a, 0xe4, 0x31, 0x42, 0xbb, 0x84,
|
||||
0x94, 0xbe, 0x82, 0xe9, 0xd4, 0xec, 0xf4, 0x94, 0x1a, 0x99, 0x7c, 0x80, 0x6e, 0x95, 0xd5, 0x84,
|
||||
0xb8, 0x11, 0x79, 0xbd, 0x6a, 0x5a, 0x43, 0xca, 0x07, 0xc7, 0x55, 0x5c, 0x48, 0xbc, 0xe3, 0x0f,
|
||||
0x66, 0xbf, 0x3d, 0xda, 0xe3, 0xea, 0xd6, 0xe8, 0x57, 0xed, 0x5f, 0x9b, 0xc5, 0x6a, 0xe5, 0x18,
|
||||
0xa6, 0x3e, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x0d, 0x8e, 0xe4, 0xf2, 0x3c, 0x05, 0x00, 0x00,
|
||||
}
|
||||
|
@ -12,20 +12,6 @@ import "node.proto";
|
||||
import "piecestore.proto";
|
||||
import "orders.proto";
|
||||
|
||||
// PointerDB defines the interface for interacting with the network state persistence layer
|
||||
service PointerDB {
|
||||
// Put formats and hands off a file path to be saved to boltdb
|
||||
rpc Put(PutRequest) returns (PutResponse);
|
||||
// Get formats and hands off a file path to get a small value from boltdb
|
||||
rpc Get(GetRequest) returns (GetResponse);
|
||||
// List calls the bolt client's List function and returns all file paths
|
||||
rpc List(ListRequest) returns (ListResponse);
|
||||
// Delete formats and hands off a file path to delete from boltdb
|
||||
rpc Delete(DeleteRequest) returns (DeleteResponse);
|
||||
// PayerBandwidthAllocation returns signed payer bandwidth allocation struct
|
||||
rpc PayerBandwidthAllocation(PayerBandwidthAllocationRequest) returns (PayerBandwidthAllocationResponse);
|
||||
}
|
||||
|
||||
message RedundancyScheme {
|
||||
enum SchemeType {
|
||||
RS = 0;
|
||||
@ -72,39 +58,6 @@ message Pointer {
|
||||
bytes metadata = 8;
|
||||
}
|
||||
|
||||
// PutRequest is a request message for the Put rpc call
|
||||
message PutRequest {
|
||||
string path = 1;
|
||||
Pointer pointer = 2;
|
||||
}
|
||||
|
||||
// GetRequest is a request message for the Get rpc call
|
||||
message GetRequest {
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
// ListRequest is a request message for the List rpc call
|
||||
message ListRequest {
|
||||
string prefix = 1;
|
||||
string start_after = 2;
|
||||
string end_before = 3;
|
||||
bool recursive = 4;
|
||||
int32 limit = 5;
|
||||
fixed32 meta_flags = 6;
|
||||
}
|
||||
|
||||
// PutResponse is a response message for the Put rpc call
|
||||
message PutResponse {
|
||||
}
|
||||
|
||||
// GetResponse is a response message for the Get rpc call
|
||||
message GetResponse {
|
||||
Pointer pointer = 1;
|
||||
repeated node.Node nodes = 2;
|
||||
piecestoreroutes.PayerBandwidthAllocation pba = 3;
|
||||
piecestoreroutes.SignedMessage authorization = 4;
|
||||
}
|
||||
|
||||
// ListResponse is a response message for the List rpc call
|
||||
message ListResponse {
|
||||
message Item {
|
||||
@ -116,27 +69,3 @@ message ListResponse {
|
||||
repeated Item items = 1;
|
||||
bool more = 2;
|
||||
}
|
||||
|
||||
message DeleteRequest {
|
||||
string path = 1;
|
||||
}
|
||||
|
||||
// DeleteResponse is a response message for the Delete rpc call
|
||||
message DeleteResponse {
|
||||
}
|
||||
|
||||
// IterateRequest is a request message for the Iterate rpc call
|
||||
message IterateRequest {
|
||||
string prefix = 1;
|
||||
string first = 2;
|
||||
bool recurse = 3;
|
||||
bool reverse = 4;
|
||||
}
|
||||
|
||||
message PayerBandwidthAllocationRequest {
|
||||
piecestoreroutes.BandwidthAction action = 1;
|
||||
}
|
||||
|
||||
message PayerBandwidthAllocationResponse {
|
||||
piecestoreroutes.PayerBandwidthAllocation pba = 1;
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package pointerdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/golang/protobuf/ptypes/timestamp"
|
||||
"github.com/skyrings/skyring-common/tools/uuid"
|
||||
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/pkg/certdb"
|
||||
"storj.io/storj/pkg/identity"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/storj"
|
||||
)
|
||||
|
||||
// AllocationSigner structure
|
||||
type AllocationSigner struct {
|
||||
satelliteIdentity *identity.FullIdentity
|
||||
orderExpiration int
|
||||
certdb certdb.DB
|
||||
}
|
||||
|
||||
// NewAllocationSigner creates new instance
|
||||
func NewAllocationSigner(satelliteIdentity *identity.FullIdentity, orderExpiration int, upldb certdb.DB) *AllocationSigner {
|
||||
return &AllocationSigner{
|
||||
satelliteIdentity: satelliteIdentity,
|
||||
orderExpiration: orderExpiration,
|
||||
certdb: upldb,
|
||||
}
|
||||
}
|
||||
|
||||
// PayerBandwidthAllocation returns generated payer bandwidth allocation
|
||||
func (allocation *AllocationSigner) PayerBandwidthAllocation(ctx context.Context, peerIdentity *identity.PeerIdentity, action pb.BandwidthAction) (pba *pb.OrderLimit, err error) {
|
||||
if peerIdentity == nil {
|
||||
return nil, Error.New("missing peer identity")
|
||||
}
|
||||
serialNum, err := uuid.New()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
created := time.Now().Unix()
|
||||
// convert ttl from days to seconds
|
||||
ttl := allocation.orderExpiration
|
||||
ttl *= 86400
|
||||
|
||||
// store the corresponding uplink's id and public key into certDB db
|
||||
err = allocation.certdb.SavePublicKey(ctx, peerIdentity.ID, peerIdentity.Leaf.PublicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := allocation.restrictActions(peerIdentity.ID, action); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pba = &pb.OrderLimit{
|
||||
SatelliteId: allocation.satelliteIdentity.ID,
|
||||
UplinkId: peerIdentity.ID,
|
||||
CreatedUnixSec: created,
|
||||
ExpirationUnixSec: created + int64(ttl),
|
||||
Action: action,
|
||||
SerialNumber: serialNum.String(),
|
||||
}
|
||||
err = auth.SignMessage(pba, *allocation.satelliteIdentity)
|
||||
return pba, err
|
||||
}
|
||||
|
||||
// OrderLimitParameters parameters necessary to create OrderLimit
|
||||
type OrderLimitParameters struct {
|
||||
SerialNumber storj.SerialNumber
|
||||
UplinkIdentity *identity.PeerIdentity
|
||||
StorageNodeID storj.NodeID
|
||||
PieceID storj.PieceID
|
||||
Action pb.PieceAction
|
||||
Limit int64
|
||||
PieceExpiration *timestamp.Timestamp
|
||||
}
|
||||
|
||||
// OrderLimit returns generated order limit
|
||||
func (allocation *AllocationSigner) OrderLimit(ctx context.Context, parameters OrderLimitParameters) (pba *pb.OrderLimit2, err error) {
|
||||
if parameters.UplinkIdentity == nil {
|
||||
return nil, Error.New("missing uplink identity")
|
||||
}
|
||||
|
||||
// store the corresponding uplink's id and public key into certDB db
|
||||
err = allocation.certdb.SavePublicKey(ctx, parameters.UplinkIdentity.ID, parameters.UplinkIdentity.Leaf.PublicKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := allocation.restrictActionsOrderLimit(parameters.UplinkIdentity.ID, parameters.Action); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// convert orderExpiration from days to timstamp
|
||||
orderExpiration, err := ptypes.TimestampProto(time.Now().Add(time.Duration(allocation.orderExpiration*24) * time.Hour))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pba = &pb.OrderLimit2{
|
||||
SerialNumber: parameters.SerialNumber,
|
||||
SatelliteId: allocation.satelliteIdentity.ID,
|
||||
UplinkId: parameters.UplinkIdentity.ID,
|
||||
StorageNodeId: parameters.StorageNodeID,
|
||||
PieceId: parameters.PieceID,
|
||||
Action: parameters.Action,
|
||||
Limit: parameters.Limit,
|
||||
PieceExpiration: parameters.PieceExpiration,
|
||||
OrderExpiration: orderExpiration,
|
||||
}
|
||||
|
||||
//TODO this needs to be review if make sense
|
||||
msgBytes, err := proto.Marshal(pba)
|
||||
if err != nil {
|
||||
return nil, auth.ErrMarshal.Wrap(err)
|
||||
}
|
||||
signeture, err := auth.GenerateSignature(msgBytes, allocation.satelliteIdentity)
|
||||
if err != nil {
|
||||
return nil, auth.ErrMarshal.Wrap(err)
|
||||
}
|
||||
pba.SatelliteSignature = signeture
|
||||
|
||||
return pba, err
|
||||
}
|
||||
|
||||
func (allocation *AllocationSigner) restrictActions(peerID storj.NodeID, action pb.BandwidthAction) error {
|
||||
switch action {
|
||||
case pb.BandwidthAction_GET_REPAIR, pb.BandwidthAction_PUT_REPAIR, pb.BandwidthAction_GET_AUDIT:
|
||||
if peerID != allocation.satelliteIdentity.ID {
|
||||
return errors.New("action restricted to signing satellite")
|
||||
}
|
||||
|
||||
return nil
|
||||
case pb.BandwidthAction_GET, pb.BandwidthAction_PUT:
|
||||
return nil
|
||||
default:
|
||||
return errors.New("unknown action restriction")
|
||||
}
|
||||
}
|
||||
|
||||
func (allocation *AllocationSigner) restrictActionsOrderLimit(peerID storj.NodeID, action pb.PieceAction) error {
|
||||
switch action {
|
||||
case pb.PieceAction_GET_REPAIR, pb.PieceAction_PUT_REPAIR, pb.PieceAction_GET_AUDIT:
|
||||
if peerID != allocation.satelliteIdentity.ID {
|
||||
return errors.New("action restricted to signing satellite")
|
||||
}
|
||||
|
||||
return nil
|
||||
case pb.PieceAction_GET, pb.PieceAction_PUT, pb.PieceAction_DELETE:
|
||||
return nil
|
||||
default:
|
||||
return errors.New("unknown action restriction")
|
||||
}
|
||||
}
|
@ -1,294 +0,0 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package pointerdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
||||
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/pkg/identity"
|
||||
"storj.io/storj/pkg/overlay"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/storj"
|
||||
"storj.io/storj/satellite/console"
|
||||
"storj.io/storj/storage"
|
||||
)
|
||||
|
||||
var (
|
||||
mon = monkit.Package()
|
||||
segmentError = errs.Class("segment error")
|
||||
)
|
||||
|
||||
// APIKeys is api keys store methods used by pointerdb
|
||||
type APIKeys interface {
|
||||
GetByKey(ctx context.Context, key console.APIKey) (*console.APIKeyInfo, error)
|
||||
}
|
||||
|
||||
// Server implements the network state RPC service
|
||||
type Server struct {
|
||||
logger *zap.Logger
|
||||
service *Service
|
||||
allocation *AllocationSigner
|
||||
cache *overlay.Cache
|
||||
config Config
|
||||
identity *identity.FullIdentity
|
||||
apiKeys APIKeys
|
||||
}
|
||||
|
||||
// NewServer creates instance of Server
|
||||
func NewServer(logger *zap.Logger, service *Service, allocation *AllocationSigner, cache *overlay.Cache, config Config, identity *identity.FullIdentity, apiKeys APIKeys) *Server {
|
||||
return &Server{
|
||||
logger: logger,
|
||||
service: service,
|
||||
allocation: allocation,
|
||||
cache: cache,
|
||||
config: config,
|
||||
identity: identity,
|
||||
apiKeys: apiKeys,
|
||||
}
|
||||
}
|
||||
|
||||
// Close closes resources
|
||||
func (s *Server) Close() error { return nil }
|
||||
|
||||
func (s *Server) validateAuth(ctx context.Context) (*console.APIKeyInfo, error) {
|
||||
APIKey, ok := auth.GetAPIKey(ctx)
|
||||
if !ok {
|
||||
s.logger.Error("unauthorized request: ", zap.Error(status.Errorf(codes.Unauthenticated, "Invalid API credential")))
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Invalid API credential")
|
||||
}
|
||||
|
||||
key, err := console.APIKeyFromBase64(string(APIKey))
|
||||
if err != nil {
|
||||
s.logger.Error("unauthorized request: ", zap.Error(status.Errorf(codes.Unauthenticated, "Invalid API credential")))
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Invalid API credential")
|
||||
}
|
||||
|
||||
keyInfo, err := s.apiKeys.GetByKey(ctx, *key)
|
||||
if err != nil {
|
||||
s.logger.Error("unauthorized request: ", zap.Error(status.Errorf(codes.Unauthenticated, err.Error())))
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Invalid API credential")
|
||||
}
|
||||
|
||||
return keyInfo, nil
|
||||
}
|
||||
|
||||
func (s *Server) validateSegment(req *pb.PutRequest) error {
|
||||
min := s.config.MinRemoteSegmentSize
|
||||
remote := req.GetPointer().Remote
|
||||
remoteSize := req.GetPointer().GetSegmentSize()
|
||||
|
||||
if remote != nil && remoteSize < int64(min) {
|
||||
return segmentError.New("remote segment size %d less than minimum allowed %d", remoteSize, min)
|
||||
}
|
||||
|
||||
max := s.config.MaxInlineSegmentSize.Int()
|
||||
inlineSize := len(req.GetPointer().InlineSegment)
|
||||
|
||||
if inlineSize > max {
|
||||
return segmentError.New("inline segment size %d greater than maximum allowed %d", inlineSize, max)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) filterValidPieces(pointer *pb.Pointer) error {
|
||||
if pointer.Type == pb.Pointer_REMOTE {
|
||||
var remotePieces []*pb.RemotePiece
|
||||
remote := pointer.Remote
|
||||
for _, piece := range remote.RemotePieces {
|
||||
// TODO enable verification
|
||||
|
||||
// err := auth.VerifyMsg(piece.Hash, piece.NodeId)
|
||||
// if err == nil {
|
||||
// // set to nil after verification to avoid storing in DB
|
||||
// piece.Hash = nil
|
||||
// remotePieces = append(remotePieces, piece)
|
||||
// } else {
|
||||
// // TODO satellite should send Delete request for piece that failed
|
||||
// s.logger.Warn("unable to verify piece hash: %v", zap.Error(err))
|
||||
// }
|
||||
|
||||
remotePieces = append(remotePieces, piece)
|
||||
}
|
||||
|
||||
if int32(len(remotePieces)) < remote.Redundancy.SuccessThreshold {
|
||||
return Error.New("Number of valid pieces is lower then success threshold: %v < %v",
|
||||
len(remotePieces),
|
||||
remote.Redundancy.SuccessThreshold,
|
||||
)
|
||||
}
|
||||
|
||||
remote.RemotePieces = remotePieces
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Put formats and hands off a key/value (path/pointer) to be saved to boltdb
|
||||
func (s *Server) Put(ctx context.Context, req *pb.PutRequest) (resp *pb.PutResponse, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
err = s.validateSegment(req)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
keyInfo, err := s.validateAuth(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = s.filterValidPieces(req.Pointer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
path := storj.JoinPaths(keyInfo.ProjectID.String(), req.GetPath())
|
||||
if err = s.service.Put(path, req.GetPointer()); err != nil {
|
||||
s.logger.Error("err putting pointer", zap.Error(err))
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &pb.PutResponse{}, nil
|
||||
}
|
||||
|
||||
// Get formats and hands off a file path to get from boltdb
|
||||
func (s *Server) Get(ctx context.Context, req *pb.GetRequest) (resp *pb.GetResponse, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
keyInfo, err := s.validateAuth(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
path := storj.JoinPaths(keyInfo.ProjectID.String(), req.GetPath())
|
||||
pointer, err := s.service.Get(path)
|
||||
if err != nil {
|
||||
if storage.ErrKeyNotFound.Has(err) {
|
||||
return nil, status.Errorf(codes.NotFound, err.Error())
|
||||
}
|
||||
s.logger.Error("err getting pointer", zap.Error(err))
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
pba, err := s.PayerBandwidthAllocation(ctx, &pb.PayerBandwidthAllocationRequest{Action: pb.BandwidthAction_GET})
|
||||
if err != nil {
|
||||
s.logger.Error("err getting payer bandwidth allocation", zap.Error(err))
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
nodes := []*pb.Node{}
|
||||
|
||||
var r = &pb.GetResponse{
|
||||
Pointer: pointer,
|
||||
Nodes: nil,
|
||||
Pba: pba.GetPba(),
|
||||
}
|
||||
|
||||
if !s.config.Overlay || pointer.Remote == nil {
|
||||
return r, nil
|
||||
}
|
||||
|
||||
for _, piece := range pointer.Remote.RemotePieces {
|
||||
node, err := s.cache.Get(ctx, piece.NodeId)
|
||||
if err != nil {
|
||||
s.logger.Error("Error getting node from cache", zap.String("ID", piece.NodeId.String()), zap.Error(err))
|
||||
continue
|
||||
}
|
||||
nodes = append(nodes, node)
|
||||
}
|
||||
|
||||
for _, v := range nodes {
|
||||
if v != nil {
|
||||
v.Type.DPanicOnInvalid("pdb server Get")
|
||||
}
|
||||
}
|
||||
r = &pb.GetResponse{
|
||||
Pointer: pointer,
|
||||
Nodes: nodes,
|
||||
Pba: pba.GetPba(),
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// List returns all Path keys in the Pointers bucket
|
||||
func (s *Server) List(ctx context.Context, req *pb.ListRequest) (resp *pb.ListResponse, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
keyInfo, err := s.validateAuth(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
prefix := storj.JoinPaths(keyInfo.ProjectID.String(), req.Prefix)
|
||||
items, more, err := s.service.List(prefix, req.StartAfter, req.EndBefore, req.Recursive, req.Limit, req.MetaFlags)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "ListV2: %v", err)
|
||||
}
|
||||
|
||||
return &pb.ListResponse{Items: items, More: more}, nil
|
||||
}
|
||||
|
||||
// Delete formats and hands off a file path to delete from boltdb
|
||||
func (s *Server) Delete(ctx context.Context, req *pb.DeleteRequest) (resp *pb.DeleteResponse, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
keyInfo, err := s.validateAuth(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
path := storj.JoinPaths(keyInfo.ProjectID.String(), req.GetPath())
|
||||
err = s.service.Delete(path)
|
||||
if err != nil {
|
||||
s.logger.Error("err deleting path and pointer", zap.Error(err))
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &pb.DeleteResponse{}, nil
|
||||
}
|
||||
|
||||
// Iterate iterates over items based on IterateRequest
|
||||
func (s *Server) Iterate(ctx context.Context, req *pb.IterateRequest, f func(it storage.Iterator) error) (err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
keyInfo, err := s.validateAuth(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
prefix := storj.JoinPaths(keyInfo.ProjectID.String(), req.Prefix)
|
||||
return s.service.Iterate(prefix, req.First, req.Recurse, req.Reverse, f)
|
||||
}
|
||||
|
||||
// PayerBandwidthAllocation returns OrderLimit struct, signed and with given action type
|
||||
func (s *Server) PayerBandwidthAllocation(ctx context.Context, req *pb.PayerBandwidthAllocationRequest) (res *pb.PayerBandwidthAllocationResponse, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
_, err = s.validateAuth(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO(michal) should be replaced with renter id when available
|
||||
// retrieve the public key
|
||||
pi, err := identity.PeerIdentityFromContext(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pba, err := s.allocation.PayerBandwidthAllocation(ctx, pi, req.GetAction())
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &pb.PayerBandwidthAllocationResponse{Pba: pba}, nil
|
||||
}
|
@ -1,472 +0,0 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package pointerdb_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/peer"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"storj.io/storj/internal/testidentity"
|
||||
"storj.io/storj/internal/testplanet"
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/pkg/auth/signing"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/pointerdb"
|
||||
"storj.io/storj/pkg/storage/meta"
|
||||
"storj.io/storj/pkg/storj"
|
||||
"storj.io/storj/satellite/console"
|
||||
"storj.io/storj/satellite/satellitedb"
|
||||
"storj.io/storj/storage"
|
||||
"storj.io/storj/storage/teststore"
|
||||
)
|
||||
|
||||
// mockAPIKeys is mock for api keys store of pointerdb
|
||||
type mockAPIKeys struct {
|
||||
info console.APIKeyInfo
|
||||
err error
|
||||
}
|
||||
|
||||
var (
|
||||
identities = testplanet.NewPregeneratedIdentities()
|
||||
)
|
||||
|
||||
// GetByKey return api key info for given key
|
||||
func (keys *mockAPIKeys) GetByKey(ctx context.Context, key console.APIKey) (*console.APIKeyInfo, error) {
|
||||
return &keys.info, keys.err
|
||||
}
|
||||
|
||||
func TestServicePut(t *testing.T) {
|
||||
validAPIKey := console.APIKey{}
|
||||
apiKeys := &mockAPIKeys{}
|
||||
|
||||
for i, tt := range []struct {
|
||||
apiKey []byte
|
||||
numOfValidPieces int
|
||||
numOfInvalidPieces int
|
||||
err error
|
||||
errString string
|
||||
}{
|
||||
{[]byte(validAPIKey.String()), 8, 0, nil, ""},
|
||||
{[]byte(validAPIKey.String()), 6, 0, nil, ""},
|
||||
{[]byte(validAPIKey.String()), 3, 0, nil, "pointerdb error: Number of valid pieces is lower then success threshold: 3 < 6"},
|
||||
|
||||
{[]byte(validAPIKey.String()), 6, 2, nil, ""},
|
||||
{[]byte(validAPIKey.String()), 3, 5, nil, "pointerdb error: Number of valid pieces is lower then success threshold: 3 < 6"},
|
||||
|
||||
{[]byte("wrong key"), 1, 0, nil, status.Errorf(codes.Unauthenticated, "Invalid API credential").Error()},
|
||||
{nil, 8, 0, errors.New("put error"), status.Errorf(codes.Internal, "internal error").Error()},
|
||||
} {
|
||||
ctx := context.Background()
|
||||
ctx = auth.WithAPIKey(ctx, tt.apiKey)
|
||||
|
||||
errTag := fmt.Sprintf("Test case #%d", i)
|
||||
|
||||
log := zaptest.NewLogger(t)
|
||||
db := teststore.New()
|
||||
service := pointerdb.NewService(log, db)
|
||||
s := pointerdb.NewServer(log, service, nil, nil, pointerdb.Config{}, nil, apiKeys)
|
||||
|
||||
path := "a/b/c"
|
||||
pointer := makePointer(ctx, t, tt.numOfValidPieces, tt.numOfInvalidPieces)
|
||||
|
||||
if tt.err != nil {
|
||||
db.ForceError++
|
||||
}
|
||||
|
||||
req := pb.PutRequest{Path: path, Pointer: pointer}
|
||||
_, err := s.Put(ctx, &req)
|
||||
|
||||
if err != nil {
|
||||
assert.EqualError(t, err, tt.errString, errTag)
|
||||
} else {
|
||||
assert.NoError(t, err, errTag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func makePointer(ctx context.Context, t *testing.T, numOfValidPieces, numOfInvalidPieces int) *pb.Pointer {
|
||||
pieces := make([]*pb.RemotePiece, numOfValidPieces+numOfInvalidPieces)
|
||||
for i := 0; i < numOfValidPieces; i++ {
|
||||
identity, err := identities.NewIdentity()
|
||||
assert.NoError(t, err)
|
||||
pieces[i] = &pb.RemotePiece{
|
||||
PieceNum: int32(i),
|
||||
NodeId: identity.ID,
|
||||
Hash: &pb.PieceHash{Hash: make([]byte, 32)},
|
||||
}
|
||||
|
||||
_, err = rand.Read(pieces[i].Hash.Hash)
|
||||
assert.NoError(t, err)
|
||||
signer := signing.SignerFromFullIdentity(identity)
|
||||
pieces[i].Hash, err = signing.SignPieceHash(signer, pieces[i].Hash)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
// public key did not match expected signer
|
||||
for i := numOfValidPieces; i < len(pieces); i++ {
|
||||
identity, err := identities.NewIdentity()
|
||||
assert.NoError(t, err)
|
||||
pieces[i] = &pb.RemotePiece{
|
||||
PieceNum: int32(i),
|
||||
NodeId: storj.NodeID{byte(i)},
|
||||
Hash: &pb.PieceHash{Hash: make([]byte, 32)},
|
||||
}
|
||||
|
||||
_, err = rand.Read(pieces[i].Hash.Hash)
|
||||
assert.NoError(t, err)
|
||||
signer := signing.SignerFromFullIdentity(identity)
|
||||
pieces[i].Hash, err = signing.SignPieceHash(signer, pieces[i].Hash)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
pointer := &pb.Pointer{
|
||||
Type: pb.Pointer_REMOTE,
|
||||
Remote: &pb.RemoteSegment{
|
||||
Redundancy: &pb.RedundancyScheme{
|
||||
MinReq: 2,
|
||||
RepairThreshold: 4,
|
||||
SuccessThreshold: 6,
|
||||
Total: 8,
|
||||
},
|
||||
RemotePieces: pieces,
|
||||
},
|
||||
}
|
||||
|
||||
return pointer
|
||||
}
|
||||
|
||||
func TestServiceGet(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ca, err := testidentity.NewTestCA(ctx)
|
||||
assert.NoError(t, err)
|
||||
identity, err := ca.NewIdentity()
|
||||
assert.NoError(t, err)
|
||||
|
||||
peerCertificates := make([]*x509.Certificate, 2)
|
||||
peerCertificates[0] = identity.Leaf
|
||||
peerCertificates[1] = identity.CA
|
||||
|
||||
info := credentials.TLSInfo{State: tls.ConnectionState{PeerCertificates: peerCertificates}}
|
||||
|
||||
validAPIKey := console.APIKey{}
|
||||
apiKeys := &mockAPIKeys{}
|
||||
// creating in-memory db and opening connection
|
||||
satdb, err := satellitedb.NewInMemory(zaptest.NewLogger(t))
|
||||
defer func() {
|
||||
err = satdb.Close()
|
||||
assert.NoError(t, err)
|
||||
}()
|
||||
err = satdb.CreateTables()
|
||||
assert.NoError(t, err)
|
||||
|
||||
for i, tt := range []struct {
|
||||
apiKey []byte
|
||||
err error
|
||||
errString string
|
||||
}{
|
||||
{[]byte(validAPIKey.String()), nil, ""},
|
||||
{[]byte("wrong key"), nil, status.Errorf(codes.Unauthenticated, "Invalid API credential").Error()},
|
||||
{nil, errors.New("get error"), status.Errorf(codes.Internal, "internal error").Error()},
|
||||
} {
|
||||
ctx = auth.WithAPIKey(ctx, tt.apiKey)
|
||||
ctx = peer.NewContext(ctx, &peer.Peer{AuthInfo: info})
|
||||
|
||||
errTag := fmt.Sprintf("Test case #%d", i)
|
||||
|
||||
db := teststore.New()
|
||||
service := pointerdb.NewService(zap.NewNop(), db)
|
||||
allocation := pointerdb.NewAllocationSigner(identity, 45, satdb.CertDB())
|
||||
|
||||
s := pointerdb.NewServer(zap.NewNop(), service, allocation, nil, pointerdb.Config{}, identity, apiKeys)
|
||||
|
||||
path := "a/b/c"
|
||||
|
||||
pr := &pb.Pointer{SegmentSize: 123}
|
||||
prBytes, err := proto.Marshal(pr)
|
||||
assert.NoError(t, err, errTag)
|
||||
|
||||
_ = db.Put(storage.Key(storj.JoinPaths(apiKeys.info.ProjectID.String(), path)), storage.Value(prBytes))
|
||||
|
||||
if tt.err != nil {
|
||||
db.ForceError++
|
||||
}
|
||||
|
||||
req := pb.GetRequest{Path: path}
|
||||
resp, err := s.Get(ctx, &req)
|
||||
|
||||
if err != nil {
|
||||
assert.EqualError(t, err, tt.errString, errTag)
|
||||
} else {
|
||||
assert.NoError(t, err, errTag)
|
||||
assert.NoError(t, err, errTag)
|
||||
assert.True(t, pb.Equal(pr, resp.Pointer), errTag)
|
||||
|
||||
assert.NotNil(t, resp.GetPba())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceDelete(t *testing.T) {
|
||||
validAPIKey := console.APIKey{}
|
||||
apiKeys := &mockAPIKeys{}
|
||||
|
||||
for i, tt := range []struct {
|
||||
apiKey []byte
|
||||
err error
|
||||
errString string
|
||||
}{
|
||||
{[]byte(validAPIKey.String()), nil, ""},
|
||||
{[]byte("wrong key"), nil, status.Errorf(codes.Unauthenticated, "Invalid API credential").Error()},
|
||||
{nil, errors.New("delete error"), status.Errorf(codes.Internal, "internal error").Error()},
|
||||
} {
|
||||
ctx := context.Background()
|
||||
ctx = auth.WithAPIKey(ctx, tt.apiKey)
|
||||
|
||||
errTag := fmt.Sprintf("Test case #%d", i)
|
||||
|
||||
path := "a/b/c"
|
||||
|
||||
db := teststore.New()
|
||||
_ = db.Put(storage.Key(storj.JoinPaths(apiKeys.info.ProjectID.String(), path)), storage.Value("hello"))
|
||||
service := pointerdb.NewService(zap.NewNop(), db)
|
||||
s := pointerdb.NewServer(zap.NewNop(), service, nil, nil, pointerdb.Config{}, nil, apiKeys)
|
||||
|
||||
if tt.err != nil {
|
||||
db.ForceError++
|
||||
}
|
||||
|
||||
req := pb.DeleteRequest{Path: path}
|
||||
_, err := s.Delete(ctx, &req)
|
||||
|
||||
if err != nil {
|
||||
assert.EqualError(t, err, tt.errString, errTag)
|
||||
} else {
|
||||
assert.NoError(t, err, errTag)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceList(t *testing.T) {
|
||||
validAPIKey := console.APIKey{}
|
||||
apiKeys := &mockAPIKeys{}
|
||||
|
||||
db := teststore.New()
|
||||
service := pointerdb.NewService(zap.NewNop(), db)
|
||||
server := pointerdb.NewServer(zap.NewNop(), service, nil, nil, pointerdb.Config{}, nil, apiKeys)
|
||||
|
||||
pointer := &pb.Pointer{}
|
||||
pointer.CreationDate = ptypes.TimestampNow()
|
||||
|
||||
pointerBytes, err := proto.Marshal(pointer)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pointerValue := storage.Value(pointerBytes)
|
||||
|
||||
items := []storage.ListItem{
|
||||
{Key: storage.Key("sample.😶"), Value: pointerValue},
|
||||
{Key: storage.Key("müsic"), Value: pointerValue},
|
||||
{Key: storage.Key("müsic/söng1.mp3"), Value: pointerValue},
|
||||
{Key: storage.Key("müsic/söng2.mp3"), Value: pointerValue},
|
||||
{Key: storage.Key("müsic/album/söng3.mp3"), Value: pointerValue},
|
||||
{Key: storage.Key("müsic/söng4.mp3"), Value: pointerValue},
|
||||
{Key: storage.Key("ビデオ/movie.mkv"), Value: pointerValue},
|
||||
}
|
||||
|
||||
for i := range items {
|
||||
items[i].Key = storage.Key(storj.JoinPaths(apiKeys.info.ProjectID.String(), items[i].Key.String()))
|
||||
}
|
||||
|
||||
err = storage.PutAll(db, items...)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
type Test struct {
|
||||
APIKey string
|
||||
Request pb.ListRequest
|
||||
Expected *pb.ListResponse
|
||||
Error func(i int, err error)
|
||||
}
|
||||
|
||||
// TODO: ZZZ temporarily disabled until endpoint and service split
|
||||
// errorWithCode := func(code codes.Code) func(i int, err error) {
|
||||
// t.Helper()
|
||||
// return func(i int, err error) {
|
||||
// t.Helper()
|
||||
// if status.Code(err) != code {
|
||||
// t.Fatalf("%d: should fail with %v, got: %v", i, code, err)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
tests := []Test{
|
||||
{
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{Recursive: true},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "müsic"},
|
||||
{Path: "müsic/album/söng3.mp3"},
|
||||
{Path: "müsic/söng1.mp3"},
|
||||
{Path: "müsic/söng2.mp3"},
|
||||
{Path: "müsic/söng4.mp3"},
|
||||
{Path: "sample.😶"},
|
||||
{Path: "ビデオ/movie.mkv"},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{Recursive: true, MetaFlags: meta.All},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "müsic", Pointer: pointer},
|
||||
{Path: "müsic/album/söng3.mp3", Pointer: pointer},
|
||||
{Path: "müsic/söng1.mp3", Pointer: pointer},
|
||||
{Path: "müsic/söng2.mp3", Pointer: pointer},
|
||||
{Path: "müsic/söng4.mp3", Pointer: pointer},
|
||||
{Path: "sample.😶", Pointer: pointer},
|
||||
{Path: "ビデオ/movie.mkv", Pointer: pointer},
|
||||
},
|
||||
},
|
||||
},
|
||||
// { // TODO: ZZZ temporarily disabled until endpoint and service split
|
||||
// APIKey: "wrong key",
|
||||
// Request: pb.ListRequest{Recursive: true, MetaFlags: meta.All}, //, APIKey: []byte("wrong key")},
|
||||
// Error: errorWithCode(codes.Unauthenticated),
|
||||
// },
|
||||
{
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{Recursive: true, Limit: 3},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "müsic"},
|
||||
{Path: "müsic/album/söng3.mp3"},
|
||||
{Path: "müsic/söng1.mp3"},
|
||||
},
|
||||
More: true,
|
||||
},
|
||||
}, {
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{MetaFlags: meta.All},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "müsic", Pointer: pointer},
|
||||
{Path: "müsic/", IsPrefix: true},
|
||||
{Path: "sample.😶", Pointer: pointer},
|
||||
{Path: "ビデオ/", IsPrefix: true},
|
||||
},
|
||||
More: false,
|
||||
},
|
||||
}, {
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{EndBefore: "ビデオ"},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "müsic"},
|
||||
{Path: "müsic/", IsPrefix: true},
|
||||
{Path: "sample.😶"},
|
||||
},
|
||||
More: false,
|
||||
},
|
||||
}, {
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{Recursive: true, Prefix: "müsic/"},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "album/söng3.mp3"},
|
||||
{Path: "söng1.mp3"},
|
||||
{Path: "söng2.mp3"},
|
||||
{Path: "söng4.mp3"},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{Recursive: true, Prefix: "müsic/", StartAfter: "album/söng3.mp3"},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "söng1.mp3"},
|
||||
{Path: "söng2.mp3"},
|
||||
{Path: "söng4.mp3"},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{Prefix: "müsic/"},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "album/", IsPrefix: true},
|
||||
{Path: "söng1.mp3"},
|
||||
{Path: "söng2.mp3"},
|
||||
{Path: "söng4.mp3"},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{Prefix: "müsic/", StartAfter: "söng1.mp3"},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "söng2.mp3"},
|
||||
{Path: "söng4.mp3"},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{Prefix: "müsic/", EndBefore: "söng4.mp3"},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
{Path: "album/", IsPrefix: true},
|
||||
{Path: "söng1.mp3"},
|
||||
{Path: "söng2.mp3"},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
APIKey: validAPIKey.String(),
|
||||
Request: pb.ListRequest{Prefix: "müs", Recursive: true, EndBefore: "ic/söng4.mp3", Limit: 1},
|
||||
Expected: &pb.ListResponse{
|
||||
Items: []*pb.ListResponse_Item{
|
||||
// {Path: "ic/söng2.mp3"},
|
||||
},
|
||||
// More: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// pb.ListRequest{Prefix: "müsic/", StartAfter: "söng1.mp3", EndBefore: "söng4.mp3"},
|
||||
// failing database
|
||||
for i, test := range tests {
|
||||
ctx := context.Background()
|
||||
ctx = auth.WithAPIKey(ctx, []byte(test.APIKey))
|
||||
|
||||
resp, err := server.List(ctx, &test.Request)
|
||||
if test.Error == nil {
|
||||
if err != nil {
|
||||
t.Fatalf("%d: failed %v", i, err)
|
||||
}
|
||||
} else {
|
||||
test.Error(i, err)
|
||||
}
|
||||
|
||||
if diff := cmp.Diff(test.Expected, resp, cmp.Comparer(pb.Equal)); diff != "" {
|
||||
t.Errorf("%d: (-want +got) %v\n%s", i, test.Request.String(), diff)
|
||||
}
|
||||
}
|
||||
}
|
179
proto.lock
179
proto.lock
@ -2864,95 +2864,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PutRequest",
|
||||
"fields": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "path",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "pointer",
|
||||
"type": "Pointer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "GetRequest",
|
||||
"fields": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "path",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ListRequest",
|
||||
"fields": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "prefix",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "start_after",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "end_before",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "recursive",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "limit",
|
||||
"type": "int32"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "meta_flags",
|
||||
"type": "fixed32"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PutResponse"
|
||||
},
|
||||
{
|
||||
"name": "GetResponse",
|
||||
"fields": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "pointer",
|
||||
"type": "Pointer"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "nodes",
|
||||
"type": "node.Node",
|
||||
"is_repeated": true
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "pba",
|
||||
"type": "piecestoreroutes.PayerBandwidthAllocation"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "authorization",
|
||||
"type": "piecestoreroutes.SignedMessage"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ListResponse",
|
||||
"fields": [
|
||||
@ -2990,96 +2901,6 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DeleteRequest",
|
||||
"fields": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "path",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DeleteResponse"
|
||||
},
|
||||
{
|
||||
"name": "IterateRequest",
|
||||
"fields": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "prefix",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "first",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "recurse",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "reverse",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PayerBandwidthAllocationRequest",
|
||||
"fields": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "action",
|
||||
"type": "piecestoreroutes.BandwidthAction"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "PayerBandwidthAllocationResponse",
|
||||
"fields": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "pba",
|
||||
"type": "piecestoreroutes.PayerBandwidthAllocation"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"services": [
|
||||
{
|
||||
"name": "PointerDB",
|
||||
"rpcs": [
|
||||
{
|
||||
"name": "Put",
|
||||
"in_type": "PutRequest",
|
||||
"out_type": "PutResponse"
|
||||
},
|
||||
{
|
||||
"name": "Get",
|
||||
"in_type": "GetRequest",
|
||||
"out_type": "GetResponse"
|
||||
},
|
||||
{
|
||||
"name": "List",
|
||||
"in_type": "ListRequest",
|
||||
"out_type": "ListResponse"
|
||||
},
|
||||
{
|
||||
"name": "Delete",
|
||||
"in_type": "DeleteRequest",
|
||||
"out_type": "DeleteResponse"
|
||||
},
|
||||
{
|
||||
"name": "PayerBandwidthAllocation",
|
||||
"in_type": "PayerBandwidthAllocationRequest",
|
||||
"out_type": "PayerBandwidthAllocationResponse"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"imports": [
|
||||
|
@ -174,10 +174,10 @@ func (endpoint *Endpoint) CommitSegment(ctx context.Context, req *pb.SegmentComm
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
// err = endpoint.filterValidPieces(req.Pointer)
|
||||
// if err != nil {
|
||||
// return nil, status.Errorf(codes.Internal, err.Error())
|
||||
// }
|
||||
err = endpoint.filterValidPieces(req.Pointer)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
path, err := endpoint.createPath(keyInfo.ProjectID, req.Segment, req.Bucket, req.Path)
|
||||
if err != nil {
|
||||
|
160
satellite/metainfo/metainfo_test.go
Normal file
160
satellite/metainfo/metainfo_test.go
Normal file
@ -0,0 +1,160 @@
|
||||
// Copyright (C) 2019 Storj Labs, Inc.
|
||||
// See LICENSE for copying information.
|
||||
|
||||
package metainfo_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/zeebo/errs"
|
||||
|
||||
"storj.io/storj/internal/testcontext"
|
||||
"storj.io/storj/internal/testplanet"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/storj"
|
||||
"storj.io/storj/satellite/console"
|
||||
)
|
||||
|
||||
// mockAPIKeys is mock for api keys store of pointerdb
|
||||
type mockAPIKeys struct {
|
||||
info console.APIKeyInfo
|
||||
err error
|
||||
}
|
||||
|
||||
// GetByKey return api key info for given key
|
||||
func (keys *mockAPIKeys) GetByKey(ctx context.Context, key console.APIKey) (*console.APIKeyInfo, error) {
|
||||
return &keys.info, keys.err
|
||||
}
|
||||
|
||||
func TestInvalidAPIKey(t *testing.T) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
planet, err := testplanet.New(t, 1, 1, 1)
|
||||
require.NoError(t, err)
|
||||
defer ctx.Check(planet.Shutdown)
|
||||
|
||||
planet.Start(ctx)
|
||||
|
||||
for _, invalidAPIKey := range []string{"", "invalid", "testKey"} {
|
||||
client, err := planet.Uplinks[0].DialMetainfo(ctx, planet.Satellites[0], invalidAPIKey)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, _, err = client.CreateSegment(ctx, "hello", "world", 1, &pb.RedundancyScheme{}, 123, time.Now())
|
||||
assertUnauthenticated(t, err)
|
||||
|
||||
_, err = client.CommitSegment(ctx, "testbucket", "testpath", 0, &pb.Pointer{}, nil)
|
||||
assertUnauthenticated(t, err)
|
||||
|
||||
_, err = client.SegmentInfo(ctx, "testbucket", "testpath", 0)
|
||||
assertUnauthenticated(t, err)
|
||||
|
||||
_, _, err = client.ReadSegment(ctx, "testbucket", "testpath", 0)
|
||||
assertUnauthenticated(t, err)
|
||||
|
||||
_, err = client.DeleteSegment(ctx, "testbucket", "testpath", 0)
|
||||
assertUnauthenticated(t, err)
|
||||
|
||||
_, _, err = client.ListSegments(ctx, "testbucket", "", "", "", true, 1, 0)
|
||||
assertUnauthenticated(t, err)
|
||||
}
|
||||
}
|
||||
|
||||
func assertUnauthenticated(t *testing.T, err error) {
|
||||
t.Helper()
|
||||
|
||||
if err, ok := status.FromError(errs.Unwrap(err)); ok {
|
||||
assert.Equal(t, codes.Unauthenticated, err.Code())
|
||||
} else {
|
||||
assert.Fail(t, "got unexpected error", "%T", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestServiceList(t *testing.T) {
|
||||
ctx := testcontext.New(t)
|
||||
defer ctx.Cleanup()
|
||||
|
||||
planet, err := testplanet.New(t, 1, 6, 1)
|
||||
require.NoError(t, err)
|
||||
defer ctx.Check(planet.Shutdown)
|
||||
|
||||
planet.Start(ctx)
|
||||
|
||||
items := []struct {
|
||||
Key string
|
||||
Value []byte
|
||||
}{
|
||||
{Key: "sample.😶", Value: []byte{1}},
|
||||
{Key: "müsic", Value: []byte{2}},
|
||||
{Key: "müsic/söng1.mp3", Value: []byte{3}},
|
||||
{Key: "müsic/söng2.mp3", Value: []byte{4}},
|
||||
{Key: "müsic/album/söng3.mp3", Value: []byte{5}},
|
||||
{Key: "müsic/söng4.mp3", Value: []byte{6}},
|
||||
{Key: "ビデオ/movie.mkv", Value: []byte{7}},
|
||||
}
|
||||
|
||||
for _, item := range items {
|
||||
err := planet.Uplinks[0].Upload(ctx, planet.Satellites[0], "testbucket", item.Key, item.Value)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
config := planet.Uplinks[0].GetConfig(planet.Satellites[0])
|
||||
metainfo, _, err := config.GetMetainfo(ctx, planet.Uplinks[0].Identity)
|
||||
require.NoError(t, err)
|
||||
|
||||
type Test struct {
|
||||
Request storj.ListOptions
|
||||
Expected storj.ObjectList // objects are partial
|
||||
}
|
||||
|
||||
list, err := metainfo.ListObjects(ctx, "testbucket", storj.ListOptions{Recursive: true, Direction: storj.After})
|
||||
require.NoError(t, err)
|
||||
|
||||
expected := []storj.Object{
|
||||
{Path: "müsic"},
|
||||
{Path: "müsic/album/söng3.mp3"},
|
||||
{Path: "müsic/söng1.mp3"},
|
||||
{Path: "müsic/söng2.mp3"},
|
||||
{Path: "müsic/söng4.mp3"},
|
||||
{Path: "sample.😶"},
|
||||
{Path: "ビデオ/movie.mkv"},
|
||||
}
|
||||
|
||||
require.Equal(t, len(expected), len(list.Items))
|
||||
sort.Slice(list.Items, func(i, k int) bool {
|
||||
return list.Items[i].Path < list.Items[k].Path
|
||||
})
|
||||
for i, item := range expected {
|
||||
require.Equal(t, item.Path, list.Items[i].Path)
|
||||
require.Equal(t, item.IsPrefix, list.Items[i].IsPrefix)
|
||||
}
|
||||
|
||||
list, err = metainfo.ListObjects(ctx, "testbucket", storj.ListOptions{Recursive: false, Direction: storj.After})
|
||||
require.NoError(t, err)
|
||||
|
||||
expected = []storj.Object{
|
||||
{Path: "müsic"},
|
||||
{Path: "müsic/", IsPrefix: true},
|
||||
{Path: "sample.😶"},
|
||||
{Path: "ビデオ/", IsPrefix: true},
|
||||
}
|
||||
|
||||
require.Equal(t, len(expected), len(list.Items))
|
||||
sort.Slice(list.Items, func(i, k int) bool {
|
||||
return list.Items[i].Path < list.Items[k].Path
|
||||
})
|
||||
for i, item := range expected {
|
||||
fmt.Println(item.Path, list.Items[i].Path)
|
||||
require.Equal(t, item.Path, list.Items[i].Path)
|
||||
require.Equal(t, item.IsPrefix, list.Items[i].IsPrefix)
|
||||
}
|
||||
}
|
@ -141,11 +141,9 @@ type Peer struct {
|
||||
}
|
||||
|
||||
Metainfo struct {
|
||||
Database storage.KeyValueStore // TODO: move into pointerDB
|
||||
Allocation *pointerdb.AllocationSigner
|
||||
Service *pointerdb.Service
|
||||
Endpoint *pointerdb.Server
|
||||
Endpoint2 *metainfo.Endpoint
|
||||
Database storage.KeyValueStore // TODO: move into pointerDB
|
||||
Service *pointerdb.Service
|
||||
Endpoint2 *metainfo.Endpoint
|
||||
}
|
||||
|
||||
Agreements struct {
|
||||
@ -318,13 +316,6 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config *Config) (*
|
||||
|
||||
peer.Metainfo.Database = storelogger.New(peer.Log.Named("pdb"), db)
|
||||
peer.Metainfo.Service = pointerdb.NewService(peer.Log.Named("pointerdb"), peer.Metainfo.Database)
|
||||
peer.Metainfo.Allocation = pointerdb.NewAllocationSigner(peer.Identity, config.PointerDB.BwExpiration, peer.DB.CertDB())
|
||||
peer.Metainfo.Endpoint = pointerdb.NewServer(peer.Log.Named("pointerdb:endpoint"),
|
||||
peer.Metainfo.Service,
|
||||
peer.Metainfo.Allocation,
|
||||
peer.Overlay.Service,
|
||||
config.PointerDB,
|
||||
peer.Identity, peer.DB.Console().APIKeys())
|
||||
|
||||
peer.Metainfo.Endpoint2 = metainfo.NewEndpoint(
|
||||
peer.Log.Named("metainfo:endpoint"),
|
||||
@ -334,8 +325,6 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config *Config) (*
|
||||
peer.DB.Console().APIKeys(),
|
||||
)
|
||||
|
||||
pb.RegisterPointerDBServer(peer.Server.GRPC(), peer.Metainfo.Endpoint)
|
||||
|
||||
pb.RegisterMetainfoServer(peer.Server.GRPC(), peer.Metainfo.Endpoint2)
|
||||
}
|
||||
|
||||
@ -378,7 +367,6 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, config *Config) (*
|
||||
peer.Audit.Service, err = audit.NewService(peer.Log.Named("audit"),
|
||||
config,
|
||||
peer.Metainfo.Service,
|
||||
peer.Metainfo.Allocation,
|
||||
peer.Orders.Service,
|
||||
peer.Transport,
|
||||
peer.Overlay.Service,
|
||||
@ -577,9 +565,6 @@ func (peer *Peer) Close() error {
|
||||
errlist.Add(peer.Agreements.Endpoint.Close())
|
||||
}
|
||||
|
||||
if peer.Metainfo.Endpoint != nil {
|
||||
errlist.Add(peer.Metainfo.Endpoint.Close())
|
||||
}
|
||||
if peer.Metainfo.Database != nil {
|
||||
errlist.Add(peer.Metainfo.Database.Close())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user