Piecestore proto change (#556)

* add action and storage node id to piecestore.proto. renamed payer and renter to satellite_id and uplink_id
This commit is contained in:
Alexander Leitner 2018-10-30 15:03:41 -04:00 committed by GitHub
parent 7ce94627f1
commit 7e4149138a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 229 additions and 119 deletions

View File

@ -13,10 +13,12 @@ import (
"path/filepath"
"time"
"github.com/gogo/protobuf/proto"
"github.com/spf13/cobra"
"github.com/zeebo/errs"
"google.golang.org/grpc"
"storj.io/storj/pkg/node"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/piecestore/rpc/client"
"storj.io/storj/pkg/provider"
@ -49,7 +51,9 @@ func main() {
}
defer printError(conn.Close)
psClient, err := client.NewPSClient(conn, 1024*32, identity.Key.(*ecdsa.PrivateKey))
nodeID := node.IDFromString("test-node-id-1234567")
psClient, err := client.NewPSClient(conn, nodeID, 1024*32, identity.Key.(*ecdsa.PrivateKey))
if err != nil {
log.Fatalf("could not initialize PSClient: %s", err)
}
@ -91,7 +95,20 @@ func main() {
id := client.NewPieceID()
if err := psClient.Put(context.Background(), id, dataSection, ttl, &pb.PayerBandwidthAllocation{}, nil); err != nil {
allocationData := &pb.PayerBandwidthAllocation_Data{
Action: pb.PayerBandwidthAllocation_PUT,
}
serializedAllocation, err := proto.Marshal(allocationData)
if err != nil {
return err
}
pba := &pb.PayerBandwidthAllocation{
Data: serializedAllocation,
}
if err := psClient.Put(context.Background(), id, dataSection, ttl, pba, nil); err != nil {
fmt.Printf("Failed to Store data of id: %s\n", id)
return err
}
@ -140,7 +157,20 @@ func main() {
return err
}
rr, err := psClient.Get(ctx, client.PieceID(id), pieceInfo.Size, &pb.PayerBandwidthAllocation{}, nil)
allocationData := &pb.PayerBandwidthAllocation_Data{
Action: pb.PayerBandwidthAllocation_GET,
}
serializedAllocation, err := proto.Marshal(allocationData)
if err != nil {
return err
}
pba := &pb.PayerBandwidthAllocation{
Data: serializedAllocation,
}
rr, err := psClient.Get(ctx, client.PieceID(id), pieceInfo.Size, pba, nil)
if err != nil {
fmt.Printf("Failed to retrieve file of id: %s\n", id)
errRemove := os.Remove(outputDir)

View File

@ -8,6 +8,7 @@ import (
"context"
"io"
"github.com/gogo/protobuf/proto"
"github.com/vivint/infectious"
monkit "gopkg.in/spacemonkeygo/monkit.v2"
@ -17,7 +18,7 @@ import (
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/piecestore/rpc/client"
"storj.io/storj/pkg/provider"
proto "storj.io/storj/pkg/statdb/proto"
sdbproto "storj.io/storj/pkg/statdb/proto"
"storj.io/storj/pkg/transport"
)
@ -56,13 +57,13 @@ func NewVerifier(transport transport.Client, overlay overlay.Client, id provider
return &Verifier{downloader: newDefaultDownloader(transport, overlay, id)}
}
func (d *defaultDownloader) dial(ctx context.Context, node *pb.Node) (ps client.PSClient, err error) {
func (d *defaultDownloader) dial(ctx context.Context, storageNode *pb.Node) (ps client.PSClient, err error) {
defer mon.Task()(&ctx)(&err)
c, err := d.transport.DialNode(ctx, node)
c, err := d.transport.DialNode(ctx, storageNode)
if err != nil {
return nil, err
}
return client.NewPSClient(c, 0, d.identity.Key)
return client.NewPSClient(c, node.IDFromString(storageNode.GetId()), 0, d.identity.Key)
}
// getShare use piece store clients to download shares from a given node
@ -80,7 +81,20 @@ func (d *defaultDownloader) getShare(ctx context.Context, stripeIndex, shareSize
return s, err
}
rr, err := ps.Get(ctx, derivedPieceID, pieceSize, &pb.PayerBandwidthAllocation{}, authorization)
allocationData := &pb.PayerBandwidthAllocation_Data{
Action: pb.PayerBandwidthAllocation_GET,
}
serializedAllocation, err := proto.Marshal(allocationData)
if err != nil {
return s, err
}
pba := &pb.PayerBandwidthAllocation{
Data: serializedAllocation,
}
rr, err := ps.Get(ctx, derivedPieceID, pieceSize, pba, authorization)
if err != nil {
return s, err
}
@ -197,7 +211,7 @@ func calcPadded(size int64, blockSize int) int64 {
}
// verify downloads shares then verifies the data correctness at the given stripe
func (verifier *Verifier) verify(ctx context.Context, stripeIndex int, pointer *pb.Pointer, authorization *pb.SignedMessage) (verifiedNodes []*proto.Node, err error) {
func (verifier *Verifier) verify(ctx context.Context, stripeIndex int, pointer *pb.Pointer, authorization *pb.SignedMessage) (verifiedNodes []*sdbproto.Node, err error) {
defer mon.Task()(&ctx)(&err)
shares, nodes, err := verifier.downloader.DownloadShares(ctx, pointer, stripeIndex, authorization)
@ -249,7 +263,7 @@ func getSuccessNodes(ctx context.Context, nodes []*pb.Node, failedNodes, offline
}
// setVerifiedNodes creates a combined array of offline nodes, failed audit nodes, and success nodes with their stats set to the statdb proto Node type
func setVerifiedNodes(ctx context.Context, nodes []*pb.Node, offlineNodes, failedNodes, successNodes []string) (verifiedNodes []*proto.Node) {
func setVerifiedNodes(ctx context.Context, nodes []*pb.Node, offlineNodes, failedNodes, successNodes []string) (verifiedNodes []*sdbproto.Node) {
offlineStatusNodes := setOfflineStatus(ctx, offlineNodes)
failStatusNodes := setAuditFailStatus(ctx, failedNodes)
successStatusNodes := setSuccessStatus(ctx, successNodes)

View File

@ -23,6 +23,29 @@ var _ = math.Inf
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
type PayerBandwidthAllocation_Action int32
const (
PayerBandwidthAllocation_PUT PayerBandwidthAllocation_Action = 0
PayerBandwidthAllocation_GET PayerBandwidthAllocation_Action = 1
)
var PayerBandwidthAllocation_Action_name = map[int32]string{
0: "PUT",
1: "GET",
}
var PayerBandwidthAllocation_Action_value = map[string]int32{
"PUT": 0,
"GET": 1,
}
func (x PayerBandwidthAllocation_Action) String() string {
return proto.EnumName(PayerBandwidthAllocation_Action_name, int32(x))
}
func (PayerBandwidthAllocation_Action) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{0, 0}
}
type PayerBandwidthAllocation struct {
Signature []byte `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
@ -35,7 +58,7 @@ func (m *PayerBandwidthAllocation) Reset() { *m = PayerBandwidthAllocati
func (m *PayerBandwidthAllocation) String() string { return proto.CompactTextString(m) }
func (*PayerBandwidthAllocation) ProtoMessage() {}
func (*PayerBandwidthAllocation) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_13a9a597c2abd9cf, []int{0}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{0}
}
func (m *PayerBandwidthAllocation) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PayerBandwidthAllocation.Unmarshal(m, b)
@ -70,21 +93,22 @@ func (m *PayerBandwidthAllocation) GetData() []byte {
}
type PayerBandwidthAllocation_Data struct {
Payer []byte `protobuf:"bytes,1,opt,name=payer,proto3" json:"payer,omitempty"`
Renter []byte `protobuf:"bytes,2,opt,name=renter,proto3" json:"renter,omitempty"`
MaxSize int64 `protobuf:"varint,3,opt,name=max_size,json=maxSize,proto3" json:"max_size,omitempty"`
ExpirationUnixSec int64 `protobuf:"varint,4,opt,name=expiration_unix_sec,json=expirationUnixSec,proto3" json:"expiration_unix_sec,omitempty"`
SerialNumber string `protobuf:"bytes,5,opt,name=serial_number,json=serialNumber,proto3" json:"serial_number,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
SatelliteId []byte `protobuf:"bytes,1,opt,name=satellite_id,json=satelliteId,proto3" json:"satellite_id,omitempty"`
UplinkId []byte `protobuf:"bytes,2,opt,name=uplink_id,json=uplinkId,proto3" json:"uplink_id,omitempty"`
MaxSize int64 `protobuf:"varint,3,opt,name=max_size,json=maxSize,proto3" json:"max_size,omitempty"`
ExpirationUnixSec int64 `protobuf:"varint,4,opt,name=expiration_unix_sec,json=expirationUnixSec,proto3" json:"expiration_unix_sec,omitempty"`
SerialNumber string `protobuf:"bytes,5,opt,name=serial_number,json=serialNumber,proto3" json:"serial_number,omitempty"`
Action PayerBandwidthAllocation_Action `protobuf:"varint,6,opt,name=action,proto3,enum=piecestoreroutes.PayerBandwidthAllocation_Action" json:"action,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PayerBandwidthAllocation_Data) Reset() { *m = PayerBandwidthAllocation_Data{} }
func (m *PayerBandwidthAllocation_Data) String() string { return proto.CompactTextString(m) }
func (*PayerBandwidthAllocation_Data) ProtoMessage() {}
func (*PayerBandwidthAllocation_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_13a9a597c2abd9cf, []int{0, 0}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{0, 0}
}
func (m *PayerBandwidthAllocation_Data) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PayerBandwidthAllocation_Data.Unmarshal(m, b)
@ -104,16 +128,16 @@ func (m *PayerBandwidthAllocation_Data) XXX_DiscardUnknown() {
var xxx_messageInfo_PayerBandwidthAllocation_Data proto.InternalMessageInfo
func (m *PayerBandwidthAllocation_Data) GetPayer() []byte {
func (m *PayerBandwidthAllocation_Data) GetSatelliteId() []byte {
if m != nil {
return m.Payer
return m.SatelliteId
}
return nil
}
func (m *PayerBandwidthAllocation_Data) GetRenter() []byte {
func (m *PayerBandwidthAllocation_Data) GetUplinkId() []byte {
if m != nil {
return m.Renter
return m.UplinkId
}
return nil
}
@ -139,6 +163,13 @@ func (m *PayerBandwidthAllocation_Data) GetSerialNumber() string {
return ""
}
func (m *PayerBandwidthAllocation_Data) GetAction() PayerBandwidthAllocation_Action {
if m != nil {
return m.Action
}
return PayerBandwidthAllocation_PUT
}
type RenterBandwidthAllocation struct {
Signature []byte `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
@ -151,7 +182,7 @@ func (m *RenterBandwidthAllocation) Reset() { *m = RenterBandwidthAlloca
func (m *RenterBandwidthAllocation) String() string { return proto.CompactTextString(m) }
func (*RenterBandwidthAllocation) ProtoMessage() {}
func (*RenterBandwidthAllocation) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_13a9a597c2abd9cf, []int{1}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{1}
}
func (m *RenterBandwidthAllocation) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RenterBandwidthAllocation.Unmarshal(m, b)
@ -188,6 +219,7 @@ func (m *RenterBandwidthAllocation) GetData() []byte {
type RenterBandwidthAllocation_Data struct {
PayerAllocation *PayerBandwidthAllocation `protobuf:"bytes,1,opt,name=payer_allocation,json=payerAllocation,proto3" json:"payer_allocation,omitempty"`
Total int64 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"`
StorageNodeId []byte `protobuf:"bytes,3,opt,name=storage_node_id,json=storageNodeId,proto3" json:"storage_node_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -197,7 +229,7 @@ func (m *RenterBandwidthAllocation_Data) Reset() { *m = RenterBandwidthA
func (m *RenterBandwidthAllocation_Data) String() string { return proto.CompactTextString(m) }
func (*RenterBandwidthAllocation_Data) ProtoMessage() {}
func (*RenterBandwidthAllocation_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_13a9a597c2abd9cf, []int{1, 0}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{1, 0}
}
func (m *RenterBandwidthAllocation_Data) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RenterBandwidthAllocation_Data.Unmarshal(m, b)
@ -231,6 +263,13 @@ func (m *RenterBandwidthAllocation_Data) GetTotal() int64 {
return 0
}
func (m *RenterBandwidthAllocation_Data) GetStorageNodeId() []byte {
if m != nil {
return m.StorageNodeId
}
return nil
}
type PieceStore struct {
Bandwidthallocation *RenterBandwidthAllocation `protobuf:"bytes,1,opt,name=bandwidthallocation,proto3" json:"bandwidthallocation,omitempty"`
Piecedata *PieceStore_PieceData `protobuf:"bytes,2,opt,name=piecedata,proto3" json:"piecedata,omitempty"`
@ -244,7 +283,7 @@ 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_piecestore_13a9a597c2abd9cf, []int{2}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{2}
}
func (m *PieceStore) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceStore.Unmarshal(m, b)
@ -298,7 +337,7 @@ 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_piecestore_13a9a597c2abd9cf, []int{2, 0}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{2, 0}
}
func (m *PieceStore_PieceData) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceStore_PieceData.Unmarshal(m, b)
@ -351,7 +390,7 @@ 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_piecestore_13a9a597c2abd9cf, []int{3}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{3}
}
func (m *PieceId) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceId.Unmarshal(m, b)
@ -398,7 +437,7 @@ 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_piecestore_13a9a597c2abd9cf, []int{4}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{4}
}
func (m *PieceSummary) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceSummary.Unmarshal(m, b)
@ -452,7 +491,7 @@ 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_piecestore_13a9a597c2abd9cf, []int{5}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{5}
}
func (m *PieceRetrieval) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceRetrieval.Unmarshal(m, b)
@ -506,7 +545,7 @@ func (m *PieceRetrieval_PieceData) Reset() { *m = PieceRetrieval_PieceDa
func (m *PieceRetrieval_PieceData) String() string { return proto.CompactTextString(m) }
func (*PieceRetrieval_PieceData) ProtoMessage() {}
func (*PieceRetrieval_PieceData) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_13a9a597c2abd9cf, []int{5, 0}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{5, 0}
}
func (m *PieceRetrieval_PieceData) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceRetrieval_PieceData.Unmarshal(m, b)
@ -559,7 +598,7 @@ 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_piecestore_13a9a597c2abd9cf, []int{6}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{6}
}
func (m *PieceRetrievalStream) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceRetrievalStream.Unmarshal(m, b)
@ -605,7 +644,7 @@ 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_piecestore_13a9a597c2abd9cf, []int{7}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{7}
}
func (m *PieceDelete) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceDelete.Unmarshal(m, b)
@ -650,7 +689,7 @@ 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_piecestore_13a9a597c2abd9cf, []int{8}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{8}
}
func (m *PieceDeleteSummary) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceDeleteSummary.Unmarshal(m, b)
@ -689,7 +728,7 @@ 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_piecestore_13a9a597c2abd9cf, []int{9}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{9}
}
func (m *PieceStoreSummary) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PieceStoreSummary.Unmarshal(m, b)
@ -733,7 +772,7 @@ func (m *StatsReq) Reset() { *m = StatsReq{} }
func (m *StatsReq) String() string { return proto.CompactTextString(m) }
func (*StatsReq) ProtoMessage() {}
func (*StatsReq) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_13a9a597c2abd9cf, []int{10}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{10}
}
func (m *StatsReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StatsReq.Unmarshal(m, b)
@ -767,7 +806,7 @@ func (m *StatSummary) Reset() { *m = StatSummary{} }
func (m *StatSummary) String() string { return proto.CompactTextString(m) }
func (*StatSummary) ProtoMessage() {}
func (*StatSummary) Descriptor() ([]byte, []int) {
return fileDescriptor_piecestore_13a9a597c2abd9cf, []int{11}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{11}
}
func (m *StatSummary) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StatSummary.Unmarshal(m, b)
@ -828,7 +867,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_piecestore_13a9a597c2abd9cf, []int{12}
return fileDescriptor_piecestore_f59ad3d0b0de7e9d, []int{12}
}
func (m *SignedMessage) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SignedMessage.Unmarshal(m, b)
@ -887,6 +926,7 @@ func init() {
proto.RegisterType((*StatsReq)(nil), "piecestoreroutes.StatsReq")
proto.RegisterType((*StatSummary)(nil), "piecestoreroutes.StatSummary")
proto.RegisterType((*SignedMessage)(nil), "piecestoreroutes.SignedMessage")
proto.RegisterEnum("piecestoreroutes.PayerBandwidthAllocation_Action", PayerBandwidthAllocation_Action_name, PayerBandwidthAllocation_Action_value)
}
// Reference imports to suppress errors if they are not otherwise used.
@ -1160,57 +1200,62 @@ var _PieceStoreRoutes_serviceDesc = grpc.ServiceDesc{
Metadata: "piecestore.proto",
}
func init() { proto.RegisterFile("piecestore.proto", fileDescriptor_piecestore_13a9a597c2abd9cf) }
func init() { proto.RegisterFile("piecestore.proto", fileDescriptor_piecestore_f59ad3d0b0de7e9d) }
var fileDescriptor_piecestore_13a9a597c2abd9cf = []byte{
// 782 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x5d, 0x4e, 0xe3, 0x48,
0x10, 0xc6, 0xce, 0x1f, 0xa9, 0x24, 0x2c, 0x34, 0x08, 0x19, 0x2b, 0xec, 0x46, 0x06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 0xff, 0x35, 0xfd,
0xf9, 0x23, 0x00, 0x00, 0xff, 0xff, 0xfa, 0x12, 0x90, 0xfa, 0x49, 0x09, 0x00, 0x00,
var fileDescriptor_piecestore_f59ad3d0b0de7e9d = []byte{
// 862 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x51, 0x6e, 0xdb, 0x46,
0x10, 0x35, 0x29, 0x59, 0x32, 0x47, 0x96, 0xa3, 0x6c, 0x82, 0x82, 0x66, 0x9d, 0x56, 0x65, 0x02,
0x43, 0x48, 0x01, 0xa1, 0x75, 0x4f, 0x90, 0x40, 0x41, 0x2a, 0x14, 0x75, 0x0d, 0x32, 0xfe, 0x09,
0x50, 0xb0, 0x2b, 0xee, 0xc4, 0x59, 0x94, 0x22, 0x59, 0x72, 0xe9, 0xca, 0xfe, 0xeb, 0x39, 0x72,
0x82, 0x1e, 0xa5, 0xa7, 0xe8, 0x01, 0xda, 0x43, 0x14, 0xdc, 0x5d, 0x91, 0x92, 0x25, 0xda, 0x45,
0xe0, 0xfc, 0x71, 0x67, 0x76, 0xde, 0xbc, 0x79, 0x7a, 0xbb, 0x2b, 0x18, 0xa4, 0x1c, 0x43, 0xcc,
0x45, 0x92, 0xe1, 0x38, 0xcd, 0x12, 0x91, 0x90, 0x95, 0x48, 0x96, 0x14, 0x02, 0x73, 0xf7, 0x5f,
0x13, 0xec, 0x33, 0x7a, 0x85, 0xd9, 0x4b, 0x1a, 0xb3, 0xdf, 0x39, 0x13, 0xef, 0x5f, 0x44, 0x51,
0x12, 0x52, 0xc1, 0x93, 0x98, 0x1c, 0x81, 0x95, 0xf3, 0x8b, 0x98, 0x8a, 0x22, 0x43, 0xdb, 0x18,
0x1a, 0xa3, 0x7d, 0xaf, 0x0e, 0x10, 0x02, 0x6d, 0x46, 0x05, 0xb5, 0x4d, 0x99, 0x90, 0xdf, 0xce,
0x1f, 0x26, 0xb4, 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xd6, 0x5f, 0x14,
0xf3, 0xe6, 0x8b, 0x72, 0x04, 0x56, 0x5a, 0xcc, 0x22, 0x1e, 0xfe, 0x80, 0x57, 0xfa, 0x66, 0xa9,
0x03, 0x27, 0x1f, 0x5a, 0x30, 0xa8, 0xe5, 0xf6, 0xe4, 0xef, 0x49, 0x26, 0xb0, 0x2b, 0x63, 0xe4,
0xb0, 0xe1, 0xb8, 0x4c, 0x99, 0xf3, 0x45, 0xd3, 0xad, 0xab, 0x54, 0x75, 0x77, 0xc8, 0x5b, 0xd8,
0xd3, 0xfe, 0x44, 0x32, 0xbc, 0xeb, 0xdc, 0x39, 0xc7, 0x77, 0xed, 0x50, 0x16, 0x77, 0x77, 0x46,
0xc6, 0x37, 0x06, 0x39, 0x85, 0x5d, 0xf5, 0xdc, 0x1c, 0xdd, 0x76, 0xf9, 0x3b, 0x4f, 0x6f, 0xcb,
0x56, 0x4c, 0x47, 0x06, 0xf9, 0x09, 0x3a, 0xfa, 0x14, 0x3c, 0x69, 0x28, 0x51, 0x69, 0xe7, 0xd9,
0xad, 0xe9, 0x7a, 0xf8, 0x49, 0x49, 0x90, 0x8a, 0x9c, 0x38, 0x5b, 0x8e, 0x8b, 0x76, 0xa2, 0xf3,
0x64, 0x7b, 0xae, 0x42, 0x79, 0xd9, 0x7e, 0x6b, 0xa6, 0xb3, 0x59, 0x47, 0xfe, 0xaf, 0xfb, 0xee,
0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x47, 0x43, 0x01, 0x53, 0xeb, 0x09, 0x00, 0x00,
}

View File

@ -18,26 +18,35 @@ service PieceStoreRoutes {
rpc Stats(StatsReq) returns (StatSummary) {}
}
message PayerBandwidthAllocation {
message Data {
bytes payer = 1;
bytes renter = 2;
int64 max_size = 3;
int64 expiration_unix_sec = 4;
string serial_number = 5;
message PayerBandwidthAllocation { // Payer refers to satellite
enum Action {
PUT = 0;
GET = 1;
}
bytes signature = 1;
bytes data = 2; // Serialization of above Data Struct
message Data {
bytes satellite_id = 1; // Satellite Identity
bytes uplink_id = 2; // Uplink Identity
int64 max_size = 3; // Max amount of data the satellite will pay for in bytes
int64 expiration_unix_sec = 4; // Unix timestamp for when data is no longer being paid for
string serial_number = 5; // Unique serial number
Action action = 6; // GET or PUT
}
bytes signature = 1; // Seralized Data signed by Satellite
bytes data = 2; // Serialization of above Data Struct
}
message RenterBandwidthAllocation {
message RenterBandwidthAllocation { // Renter refers to uplink
message Data {
PayerBandwidthAllocation payer_allocation = 1;
int64 total = 2;
PayerBandwidthAllocation payer_allocation = 1; // Bandwidth Allocation from Satellite
int64 total = 2; // Total Bytes Stored
bytes storage_node_id = 3; // Storage Node Identity
}
bytes signature = 1;
bytes data = 2; // Serialization of above Data Struct
bytes signature = 1; // Seralized Data signed by Uplink
bytes data = 2; // Serialization of above Data Struct
}
message PieceStore {

View File

@ -19,6 +19,7 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc"
"storj.io/storj/pkg/node"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/ranger"
)
@ -29,10 +30,10 @@ var ClientError = errs.Class("PSClient error")
var (
defaultBandwidthMsgSize = flag.Int(
"piecestore.rpc.client.default_bandwidth_msg_size", 32*1024,
"default bandwidth message size in kilobytes")
"default bandwidth message size in bytes")
maxBandwidthMsgSize = flag.Int(
"piecestore.rpc.client.max_bandwidth_msg_size", 64*1024,
"max bandwidth message size in kilobytes")
"max bandwidth message size in bytes")
)
// PSClient is an interface describing the functions for interacting with piecestore nodes
@ -47,14 +48,15 @@ type PSClient interface {
// Client -- Struct Info needed for protobuf api calls
type Client struct {
route pb.PieceStoreRoutesClient
conn *grpc.ClientConn
prikey crypto.PrivateKey
bandwidthMsgSize int
route pb.PieceStoreRoutesClient // Client for interacting with Storage Node
conn *grpc.ClientConn // Connection to Storage Node
prikey crypto.PrivateKey // Uplink private key
bandwidthMsgSize int // max bandwidth message size in bytes
nodeID *node.ID // Storage node being connected to
}
// NewPSClient initilizes a PSClient
func NewPSClient(conn *grpc.ClientConn, bandwidthMsgSize int, prikey crypto.PrivateKey) (PSClient, error) {
func NewPSClient(conn *grpc.ClientConn, nodeID *node.ID, bandwidthMsgSize int, prikey crypto.PrivateKey) (PSClient, error) {
if bandwidthMsgSize < 0 || bandwidthMsgSize > *maxBandwidthMsgSize {
return nil, ClientError.New(fmt.Sprintf("Invalid Bandwidth Message Size: %v", bandwidthMsgSize))
}
@ -68,11 +70,12 @@ func NewPSClient(conn *grpc.ClientConn, bandwidthMsgSize int, prikey crypto.Priv
route: pb.NewPieceStoreRoutesClient(conn),
bandwidthMsgSize: bandwidthMsgSize,
prikey: prikey,
nodeID: nodeID,
}, nil
}
// NewCustomRoute creates new Client with custom route interface
func NewCustomRoute(route pb.PieceStoreRoutesClient, bandwidthMsgSize int, prikey crypto.PrivateKey) (*Client, error) {
func NewCustomRoute(route pb.PieceStoreRoutesClient, nodeID *node.ID, bandwidthMsgSize int, prikey crypto.PrivateKey) (*Client, error) {
if bandwidthMsgSize < 0 || bandwidthMsgSize > *maxBandwidthMsgSize {
return nil, ClientError.New(fmt.Sprintf("Invalid Bandwidth Message Size: %v", bandwidthMsgSize))
}
@ -85,6 +88,7 @@ func NewCustomRoute(route pb.PieceStoreRoutesClient, bandwidthMsgSize int, prike
route: route,
bandwidthMsgSize: bandwidthMsgSize,
prikey: prikey,
nodeID: nodeID,
}, nil
}

View File

@ -16,6 +16,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"storj.io/storj/pkg/node"
"storj.io/storj/pkg/pb"
)
@ -75,7 +76,7 @@ func TestPieceRanger(t *testing.T) {
ctx := context.Background()
c, err := NewCustomRoute(route, 32*1024, priv)
c, err := NewCustomRoute(route, node.IDFromString("test-node-id-1234567"), 32*1024, priv)
assert.NoError(t, err)
rr, err := PieceRanger(ctx, c, stream, pid, &pb.PayerBandwidthAllocation{}, nil)
if assert.NoError(t, err, errTag) {
@ -146,7 +147,7 @@ func TestPieceRangerSize(t *testing.T) {
ctx := context.Background()
c, err := NewCustomRoute(route, 32*1024, priv)
c, err := NewCustomRoute(route, node.IDFromString("test-node-id-1234567"), 32*1024, priv)
assert.NoError(t, err)
rr := PieceRangerSize(c, stream, pid, tt.size, &pb.PayerBandwidthAllocation{}, nil)
assert.Equal(t, tt.size, rr.Size(), errTag)

View File

@ -28,6 +28,7 @@ func (s *StreamWriter) Write(b []byte) (int, error) {
allocationData := &pb.RenterBandwidthAllocation_Data{
PayerAllocation: s.pba,
Total: updatedAllocation,
StorageNodeId: s.signer.nodeID.Bytes(),
}
serializedAllocation, err := proto.Marshal(allocationData)
@ -108,6 +109,7 @@ func NewStreamReader(client *Client, stream pb.PieceStoreRoutes_RetrieveClient,
allocationData := &pb.RenterBandwidthAllocation_Data{
PayerAllocation: pba,
Total: sr.allocated + allocate,
StorageNodeId: sr.client.nodeID.Bytes(),
}
serializedAllocation, err := proto.Marshal(allocationData)

View File

@ -315,7 +315,11 @@ func (s *Server) getPayerBandwidthAllocation(ctx context.Context) (*pb.PayerBand
if err != nil {
return nil, err
}
pbad := &pb.PayerBandwidthAllocation_Data{Payer: payer, Renter: peerIdentity.ID.Bytes()}
pbad := &pb.PayerBandwidthAllocation_Data{
SatelliteId: payer,
UplinkId: peerIdentity.ID.Bytes(),
// TODO: Action: pb.PayerBandwidthAllocation_GET, // Action should be a GET or a PUT
}
data, err := proto.Marshal(pbad)
if err != nil {

View File

@ -14,6 +14,7 @@ import (
monkit "gopkg.in/spacemonkeygo/monkit.v2"
"storj.io/storj/pkg/eestream"
"storj.io/storj/pkg/node"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/piecestore/rpc/client"
"storj.io/storj/pkg/provider"
@ -42,15 +43,15 @@ type defaultDialer struct {
identity *provider.FullIdentity
}
func (dialer *defaultDialer) dial(ctx context.Context, node *pb.Node) (ps client.PSClient, err error) {
func (dialer *defaultDialer) dial(ctx context.Context, storageNode *pb.Node) (ps client.PSClient, err error) {
defer mon.Task()(&ctx)(&err)
conn, err := dialer.transport.DialNode(ctx, node)
conn, err := dialer.transport.DialNode(ctx, storageNode)
if err != nil {
return nil, err
}
return client.NewPSClient(conn, 0, dialer.identity.Key)
return client.NewPSClient(conn, node.IDFromString(storageNode.GetId()), 0, dialer.identity.Key)
}
type ecClient struct {