updated based on review comments (#456)
This commit is contained in:
parent
6eafd60945
commit
2b2e0996b0
@ -197,7 +197,7 @@ func main() {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("Space Used: %v, Space Available: %v\n", summary.UsedSpace, summary.AvailableSpace)
|
||||
log.Printf("Space Used: %v, Space Available: %v\nBandwidth Available: %v, Bandwidth Used: %v\n", summary.GetUsedSpace(), summary.GetAvailableSpace(), summary.GetAvailableBandwidth(), summary.GetUsedBandwidth())
|
||||
return nil
|
||||
},
|
||||
})
|
||||
|
@ -35,7 +35,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_0a2720894257684e, []int{0}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{0}
|
||||
}
|
||||
func (m *PayerBandwidthAllocation) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PayerBandwidthAllocation.Unmarshal(m, b)
|
||||
@ -84,7 +84,7 @@ func (m *PayerBandwidthAllocation_Data) Reset() { *m = PayerBandwidthAll
|
||||
func (m *PayerBandwidthAllocation_Data) String() string { return proto.CompactTextString(m) }
|
||||
func (*PayerBandwidthAllocation_Data) ProtoMessage() {}
|
||||
func (*PayerBandwidthAllocation_Data) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_piecestore_0a2720894257684e, []int{0, 0}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{0, 0}
|
||||
}
|
||||
func (m *PayerBandwidthAllocation_Data) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PayerBandwidthAllocation_Data.Unmarshal(m, b)
|
||||
@ -151,7 +151,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_0a2720894257684e, []int{1}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{1}
|
||||
}
|
||||
func (m *RenterBandwidthAllocation) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_RenterBandwidthAllocation.Unmarshal(m, b)
|
||||
@ -197,7 +197,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_0a2720894257684e, []int{1, 0}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{1, 0}
|
||||
}
|
||||
func (m *RenterBandwidthAllocation_Data) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_RenterBandwidthAllocation_Data.Unmarshal(m, b)
|
||||
@ -243,7 +243,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_0a2720894257684e, []int{2}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{2}
|
||||
}
|
||||
func (m *PieceStore) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceStore.Unmarshal(m, b)
|
||||
@ -290,7 +290,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_0a2720894257684e, []int{2, 0}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{2, 0}
|
||||
}
|
||||
func (m *PieceStore_PieceData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceStore_PieceData.Unmarshal(m, b)
|
||||
@ -342,7 +342,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_0a2720894257684e, []int{3}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{3}
|
||||
}
|
||||
func (m *PieceId) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceId.Unmarshal(m, b)
|
||||
@ -382,7 +382,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_0a2720894257684e, []int{4}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{4}
|
||||
}
|
||||
func (m *PieceSummary) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceSummary.Unmarshal(m, b)
|
||||
@ -435,7 +435,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_0a2720894257684e, []int{5}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{5}
|
||||
}
|
||||
func (m *PieceRetrieval) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceRetrieval.Unmarshal(m, b)
|
||||
@ -482,7 +482,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_0a2720894257684e, []int{5, 0}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{5, 0}
|
||||
}
|
||||
func (m *PieceRetrieval_PieceData) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceRetrieval_PieceData.Unmarshal(m, b)
|
||||
@ -535,7 +535,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_0a2720894257684e, []int{6}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{6}
|
||||
}
|
||||
func (m *PieceRetrievalStream) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceRetrievalStream.Unmarshal(m, b)
|
||||
@ -580,7 +580,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_0a2720894257684e, []int{7}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{7}
|
||||
}
|
||||
func (m *PieceDelete) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceDelete.Unmarshal(m, b)
|
||||
@ -618,7 +618,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_0a2720894257684e, []int{8}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{8}
|
||||
}
|
||||
func (m *PieceDeleteSummary) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceDeleteSummary.Unmarshal(m, b)
|
||||
@ -657,7 +657,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_0a2720894257684e, []int{9}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{9}
|
||||
}
|
||||
func (m *PieceStoreSummary) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_PieceStoreSummary.Unmarshal(m, b)
|
||||
@ -701,7 +701,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_0a2720894257684e, []int{10}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{10}
|
||||
}
|
||||
func (m *StatsReq) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_StatsReq.Unmarshal(m, b)
|
||||
@ -724,6 +724,8 @@ var xxx_messageInfo_StatsReq proto.InternalMessageInfo
|
||||
type StatSummary struct {
|
||||
UsedSpace int64 `protobuf:"varint,1,opt,name=usedSpace,proto3" json:"usedSpace,omitempty"`
|
||||
AvailableSpace int64 `protobuf:"varint,2,opt,name=availableSpace,proto3" json:"availableSpace,omitempty"`
|
||||
UsedBandwidth int64 `protobuf:"varint,3,opt,name=usedBandwidth,proto3" json:"usedBandwidth,omitempty"`
|
||||
AvailableBandwidth int64 `protobuf:"varint,4,opt,name=availableBandwidth,proto3" json:"availableBandwidth,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
@ -733,7 +735,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_0a2720894257684e, []int{11}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{11}
|
||||
}
|
||||
func (m *StatSummary) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_StatSummary.Unmarshal(m, b)
|
||||
@ -767,6 +769,20 @@ func (m *StatSummary) GetAvailableSpace() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *StatSummary) GetUsedBandwidth() int64 {
|
||||
if m != nil {
|
||||
return m.UsedBandwidth
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *StatSummary) GetAvailableBandwidth() int64 {
|
||||
if m != nil {
|
||||
return m.AvailableBandwidth
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type SignatureAuth struct {
|
||||
Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
|
||||
Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
|
||||
@ -780,7 +796,7 @@ func (m *SignatureAuth) Reset() { *m = SignatureAuth{} }
|
||||
func (m *SignatureAuth) String() string { return proto.CompactTextString(m) }
|
||||
func (*SignatureAuth) ProtoMessage() {}
|
||||
func (*SignatureAuth) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_piecestore_0a2720894257684e, []int{12}
|
||||
return fileDescriptor_piecestore_b29c3a3a1a7e53a5, []int{12}
|
||||
}
|
||||
func (m *SignatureAuth) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_SignatureAuth.Unmarshal(m, b)
|
||||
@ -1112,53 +1128,55 @@ var _PieceStoreRoutes_serviceDesc = grpc.ServiceDesc{
|
||||
Metadata: "piecestore.proto",
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("piecestore.proto", fileDescriptor_piecestore_0a2720894257684e) }
|
||||
func init() { proto.RegisterFile("piecestore.proto", fileDescriptor_piecestore_b29c3a3a1a7e53a5) }
|
||||
|
||||
var fileDescriptor_piecestore_0a2720894257684e = []byte{
|
||||
// 717 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdd, 0x4e, 0xdb, 0x4a,
|
||||
0x10, 0xc6, 0xce, 0x1f, 0x99, 0x04, 0x0e, 0x2c, 0x08, 0x39, 0x56, 0x38, 0x8a, 0x0c, 0x42, 0x11,
|
||||
0x47, 0x8a, 0x8e, 0x38, 0x4f, 0x00, 0x8a, 0x74, 0x8a, 0x2a, 0x51, 0xb4, 0x16, 0x37, 0x48, 0x55,
|
||||
0xb4, 0xb1, 0x07, 0x58, 0xc9, 0x7f, 0xb5, 0xd7, 0x34, 0x70, 0xd9, 0xa7, 0xa8, 0xd4, 0xdb, 0x3e,
|
||||
0x49, 0x5f, 0xa9, 0x2f, 0x50, 0x79, 0xfd, 0x97, 0x3f, 0x87, 0x9b, 0xf6, 0x6e, 0x67, 0x66, 0xf7,
|
||||
0x9b, 0x6f, 0xe6, 0x1b, 0x8f, 0x61, 0x2f, 0xe0, 0x68, 0x61, 0x24, 0xfc, 0x10, 0x47, 0x41, 0xe8,
|
||||
0x0b, 0x9f, 0xcc, 0x79, 0x42, 0x3f, 0x16, 0x18, 0x19, 0x3f, 0x15, 0xd0, 0x6e, 0xd9, 0x0b, 0x86,
|
||||
0x57, 0xcc, 0xb3, 0x3f, 0x73, 0x5b, 0x3c, 0x5d, 0x3a, 0x8e, 0x6f, 0x31, 0xc1, 0x7d, 0x8f, 0xf4,
|
||||
0xa1, 0x1d, 0xf1, 0x47, 0x8f, 0x89, 0x38, 0x44, 0x4d, 0x19, 0x28, 0xc3, 0x2e, 0x2d, 0x1d, 0x84,
|
||||
0x40, 0xdd, 0x66, 0x82, 0x69, 0xaa, 0x0c, 0xc8, 0xb3, 0xfe, 0x5d, 0x81, 0xfa, 0x98, 0x09, 0x46,
|
||||
0x0e, 0xa1, 0x11, 0x24, 0xb0, 0xd9, 0xb3, 0xd4, 0x20, 0x47, 0xd0, 0x0c, 0xd1, 0x13, 0x18, 0x66,
|
||||
0x8f, 0x32, 0x8b, 0xf4, 0x60, 0xdb, 0x65, 0xb3, 0x49, 0xc4, 0x5f, 0x51, 0xab, 0x0d, 0x94, 0x61,
|
||||
0x8d, 0xb6, 0x5c, 0x36, 0x33, 0xf9, 0x2b, 0x92, 0x11, 0x1c, 0xe0, 0x2c, 0xe0, 0xa1, 0x64, 0x34,
|
||||
0x89, 0x3d, 0x3e, 0x9b, 0x44, 0x68, 0x69, 0x75, 0x79, 0x6b, 0xbf, 0x0c, 0xdd, 0x79, 0x7c, 0x66,
|
||||
0xa2, 0x45, 0x4e, 0x60, 0x27, 0xc2, 0x90, 0x33, 0x67, 0xe2, 0xc5, 0xee, 0x14, 0x43, 0xad, 0x31,
|
||||
0x50, 0x86, 0x6d, 0xda, 0x4d, 0x9d, 0x37, 0xd2, 0x67, 0xfc, 0x50, 0xa0, 0x47, 0x65, 0xea, 0xdf,
|
||||
0x53, 0x76, 0x94, 0x55, 0x7d, 0x07, 0x7b, 0xb2, 0xd0, 0x09, 0x2b, 0xd0, 0x24, 0x40, 0xe7, 0xe2,
|
||||
0x7c, 0xb4, 0xdc, 0xfa, 0x51, 0x55, 0xdb, 0xe9, 0x5f, 0x12, 0x63, 0x8e, 0xd0, 0x21, 0x34, 0x84,
|
||||
0x2f, 0x98, 0x23, 0x73, 0xd6, 0x68, 0x6a, 0x18, 0x5f, 0x55, 0x80, 0xdb, 0x04, 0xd4, 0x4c, 0x40,
|
||||
0xc9, 0x47, 0x38, 0x98, 0xe6, 0x60, 0x2b, 0xe9, 0xff, 0x59, 0x4d, 0x5f, 0x59, 0x3f, 0x5d, 0x87,
|
||||
0x43, 0xc6, 0xd0, 0x96, 0x10, 0x45, 0xed, 0x9d, 0x8b, 0xb3, 0x35, 0x35, 0x15, 0x7c, 0xd2, 0x63,
|
||||
0xd2, 0x15, 0x5a, 0x3e, 0xd4, 0x11, 0xda, 0x85, 0x9f, 0xec, 0x82, 0xca, 0x6d, 0x49, 0xb0, 0x4d,
|
||||
0x55, 0x6e, 0x57, 0x49, 0xad, 0x56, 0x49, 0xad, 0x41, 0xcb, 0xf2, 0x3d, 0x81, 0x9e, 0x90, 0x43,
|
||||
0xd3, 0xa5, 0xb9, 0x69, 0xf4, 0xa0, 0x25, 0xd3, 0x5c, 0xdb, 0xcb, 0x49, 0x8c, 0x29, 0x74, 0x53,
|
||||
0x92, 0xb1, 0xeb, 0xb2, 0xf0, 0x65, 0x85, 0x04, 0x81, 0xba, 0x1c, 0xc3, 0x34, 0xab, 0x3c, 0x57,
|
||||
0x11, 0xab, 0x55, 0x10, 0x33, 0xbe, 0xa8, 0xb0, 0x2b, 0x93, 0x50, 0x14, 0x21, 0xc7, 0x67, 0xe6,
|
||||
0xfc, 0x69, 0x75, 0xde, 0x65, 0xea, 0x8c, 0x4b, 0x75, 0xce, 0x2b, 0xd4, 0x29, 0x38, 0xad, 0x28,
|
||||
0x94, 0x1c, 0xf5, 0xff, 0x37, 0x29, 0xb4, 0xae, 0x39, 0x47, 0xd0, 0xf4, 0x1f, 0x1e, 0x22, 0x14,
|
||||
0x59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
|
||||
0x6c, 0x67, 0x13, 0x80, 0x64, 0xf0, 0xd6, 0x48, 0xea, 0x67, 0x6f, 0xdd, 0x48, 0x87, 0xc8, 0xd8,
|
||||
0x1a, 0x2a, 0xff, 0x2a, 0xe4, 0x06, 0x1a, 0xe9, 0xee, 0xeb, 0x6f, 0xda, 0x44, 0xfa, 0xc9, 0xa6,
|
||||
0x68, 0xc1, 0x74, 0xa8, 0x90, 0x0f, 0xd0, 0xcc, 0xe6, 0xec, 0xb8, 0xe2, 0x49, 0x1a, 0xd6, 0x4f,
|
||||
0x37, 0x86, 0xcb, 0xe2, 0xc7, 0x09, 0x41, 0x26, 0x22, 0xa2, 0xaf, 0x3e, 0xc8, 0x47, 0x46, 0x3f,
|
||||
0x5e, 0x1f, 0x2b, 0x50, 0xae, 0xea, 0xf7, 0x6a, 0x30, 0x9d, 0x36, 0xe5, 0x2f, 0xfc, 0xbf, 0x5f,
|
||||
0x01, 0x00, 0x00, 0xff, 0xff, 0xea, 0x38, 0xb9, 0xe3, 0xd6, 0x07, 0x00, 0x00,
|
||||
var fileDescriptor_piecestore_b29c3a3a1a7e53a5 = []byte{
|
||||
// 737 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xdd, 0x4a, 0xdc, 0x40,
|
||||
0x14, 0x36, 0xd9, 0x3f, 0xf7, 0xec, 0x6a, 0x75, 0x14, 0xc9, 0x86, 0xb5, 0x2c, 0x51, 0x64, 0xb1,
|
||||
0xb0, 0x14, 0xfb, 0x04, 0xca, 0x42, 0x2b, 0x05, 0x2b, 0x09, 0xde, 0x08, 0x65, 0x99, 0x4d, 0x8e,
|
||||
0x3a, 0x90, 0x4d, 0xd2, 0x64, 0x62, 0x57, 0x2f, 0xfb, 0x14, 0x85, 0xde, 0xf6, 0xa6, 0xaf, 0xd1,
|
||||
0x57, 0xea, 0x0b, 0x94, 0xcc, 0xe4, 0x67, 0xff, 0xb2, 0xde, 0xb4, 0x77, 0x73, 0xfe, 0xbe, 0xf3,
|
||||
0x9d, 0x9f, 0x1c, 0x02, 0x3b, 0x01, 0x43, 0x1b, 0x23, 0xee, 0x87, 0x38, 0x08, 0x42, 0x9f, 0xfb,
|
||||
0x64, 0x46, 0x13, 0xfa, 0x31, 0xc7, 0xc8, 0xf8, 0xa3, 0x80, 0x76, 0x4d, 0x9f, 0x30, 0xbc, 0xa0,
|
||||
0x9e, 0xf3, 0x95, 0x39, 0xfc, 0xe1, 0xdc, 0x75, 0x7d, 0x9b, 0x72, 0xe6, 0x7b, 0xa4, 0x0b, 0xcd,
|
||||
0x88, 0xdd, 0x7b, 0x94, 0xc7, 0x21, 0x6a, 0x4a, 0x4f, 0xe9, 0xb7, 0xcd, 0x42, 0x41, 0x08, 0x54,
|
||||
0x1d, 0xca, 0xa9, 0xa6, 0x0a, 0x83, 0x78, 0xeb, 0x3f, 0x15, 0xa8, 0x0e, 0x29, 0xa7, 0x64, 0x1f,
|
||||
0x6a, 0x41, 0x02, 0x9b, 0x86, 0x49, 0x81, 0x1c, 0x40, 0x3d, 0x44, 0x8f, 0x63, 0x98, 0x06, 0xa5,
|
||||
0x12, 0xe9, 0xc0, 0xe6, 0x84, 0x4e, 0x47, 0x11, 0x7b, 0x46, 0xad, 0xd2, 0x53, 0xfa, 0x15, 0xb3,
|
||||
0x31, 0xa1, 0x53, 0x8b, 0x3d, 0x23, 0x19, 0xc0, 0x1e, 0x4e, 0x03, 0x16, 0x0a, 0x46, 0xa3, 0xd8,
|
||||
0x63, 0xd3, 0x51, 0x84, 0xb6, 0x56, 0x15, 0x5e, 0xbb, 0x85, 0xe9, 0xc6, 0x63, 0x53, 0x0b, 0x6d,
|
||||
0x72, 0x04, 0x5b, 0x11, 0x86, 0x8c, 0xba, 0x23, 0x2f, 0x9e, 0x8c, 0x31, 0xd4, 0x6a, 0x3d, 0xa5,
|
||||
0xdf, 0x34, 0xdb, 0x52, 0x79, 0x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, 0x4e, 0x67, 0x58, 0x4c, 0xe7, 0xb4, 0x64, 0x3a, 0x39, 0xa7, 0xa5, 0x09,
|
||||
0x25, 0x4f, 0xfd, 0xfd, 0xba, 0x09, 0xad, 0x6a, 0xce, 0x01, 0xd4, 0xfd, 0xbb, 0xbb, 0x08, 0x79,
|
||||
0xda, 0x8f, 0x54, 0x32, 0x86, 0xb0, 0x3f, 0x9f, 0xcf, 0xe2, 0x21, 0xd2, 0x49, 0x8e, 0xa1, 0xcc,
|
||||
0x60, 0xcc, 0x4c, 0x52, 0x9d, 0x9f, 0xe4, 0x21, 0xb4, 0x24, 0x1d, 0x74, 0x91, 0xe3, 0xd2, 0x34,
|
||||
0x07, 0x40, 0x66, 0xcc, 0xd9, 0x4c, 0x35, 0x68, 0x4c, 0x30, 0x8a, 0xe8, 0x3d, 0xa6, 0xae, 0x99,
|
||||
0x68, 0x58, 0xb0, 0x5b, 0xac, 0xe8, 0x8b, 0xee, 0xe4, 0x18, 0xb6, 0xc4, 0xb7, 0x66, 0xa2, 0x8d,
|
||||
0xec, 0x11, 0x9d, 0xb4, 0xf0, 0x79, 0xa5, 0x01, 0xb0, 0x69, 0x71, 0xca, 0x23, 0x13, 0xbf, 0x18,
|
||||
0xbf, 0x14, 0x68, 0x25, 0x42, 0x86, 0xdd, 0x85, 0x66, 0x1c, 0xa1, 0x63, 0x05, 0xd4, 0xce, 0x4a,
|
||||
0x2e, 0x14, 0xe4, 0x04, 0xb6, 0xe9, 0x23, 0x65, 0x2e, 0x1d, 0xbb, 0x28, 0x5d, 0x64, 0x82, 0x05,
|
||||
0x6d, 0xc2, 0x23, 0x09, 0xca, 0xd7, 0x21, 0x6d, 0xf5, 0xbc, 0x92, 0x0c, 0x80, 0xe4, 0x71, 0x85,
|
||||
0xab, 0xbc, 0x94, 0x2b, 0x2c, 0xc6, 0x08, 0xb6, 0xac, 0xec, 0xac, 0x9d, 0xc7, 0xfc, 0x21, 0x3f,
|
||||
0x6d, 0x4a, 0x71, 0xda, 0xe6, 0x8f, 0xa1, 0xba, 0x78, 0x0c, 0xbb, 0xd0, 0x0c, 0xe2, 0xb1, 0xcb,
|
||||
0xec, 0x8f, 0xf8, 0x94, 0x7e, 0x84, 0x85, 0xe2, 0xec, 0x47, 0x05, 0x76, 0x8a, 0x76, 0x9b, 0x62,
|
||||
0x09, 0xc9, 0x10, 0x6a, 0x42, 0x47, 0x3a, 0x25, 0x0b, 0x7a, 0xe9, 0xe8, 0xaf, 0xcb, 0x2e, 0x8b,
|
||||
0xec, 0xaa, 0xb1, 0x41, 0x6e, 0x61, 0x33, 0x5d, 0x2c, 0x24, 0xbd, 0x97, 0x36, 0x5d, 0x3f, 0x79,
|
||||
0xc9, 0x43, 0xee, 0xa6, 0xb1, 0xd1, 0x57, 0xde, 0x2a, 0xe4, 0x0a, 0x6a, 0xf2, 0xa4, 0x76, 0xd7,
|
||||
0x1d, 0x38, 0xfd, 0x68, 0x9d, 0x35, 0x67, 0xda, 0x57, 0xc8, 0x27, 0xa8, 0xa7, 0xeb, 0x7b, 0x58,
|
||||
0x12, 0x22, 0xcd, 0xfa, 0xf1, 0x5a, 0x73, 0x51, 0xfc, 0x30, 0x21, 0x48, 0x79, 0x44, 0xf4, 0xe5,
|
||||
0x80, 0x6c, 0x13, 0xf5, 0xc3, 0xd5, 0xb6, 0x1c, 0xe5, 0xa2, 0x7a, 0xab, 0x06, 0xe3, 0x71, 0x5d,
|
||||
0xfc, 0x19, 0xbc, 0xfb, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x52, 0x6c, 0xb8, 0x84, 0x2d, 0x08, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
@ -95,6 +95,8 @@ message StatsReq {}
|
||||
message StatSummary {
|
||||
int64 usedSpace = 1;
|
||||
int64 availableSpace = 2;
|
||||
int64 usedBandwidth = 3;
|
||||
int64 availableBandwidth = 4;
|
||||
}
|
||||
|
||||
message SignatureAuth {
|
||||
|
@ -301,6 +301,17 @@ func (db *DB) GetTotalBandwidthBetween(startdate time.Time, enddate time.Time) (
|
||||
return totalbwusage, errors.New("Invalid date range")
|
||||
}
|
||||
|
||||
var count int
|
||||
rows := db.DB.QueryRow("SELECT COUNT(*) as count FROM bwusagetbl")
|
||||
err = rows.Scan(&count)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if count == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
err = db.DB.QueryRow(`SELECT SUM(size) FROM bwusagetbl WHERE daystartdate BETWEEN ? AND ?`, startTimeUnix, endTimeUnix).Scan(&totalbwusage)
|
||||
return totalbwusage, err
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/gtank/cryptopasta"
|
||||
"github.com/shirou/gopsutil/disk"
|
||||
"github.com/zeebo/errs"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/net/context"
|
||||
"gopkg.in/spacemonkeygo/monkit.v2"
|
||||
|
||||
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/peertls"
|
||||
pstore "storj.io/storj/pkg/piecestore"
|
||||
@ -37,6 +37,7 @@ var (
|
||||
type Config struct {
|
||||
Path string `help:"path to store data in" default:"$CONFDIR"`
|
||||
AllocatedDiskSpace int64 `help:"total allocated disk space, default(1GB)" default:"1073741824"`
|
||||
AllocatedBandwidth int64 `help:"total allocated bandwidth, default(100GB)" default:"107374182400"`
|
||||
}
|
||||
|
||||
// Run implements provider.Responsibility
|
||||
@ -77,10 +78,11 @@ func DirSize(path string) (int64, error) {
|
||||
|
||||
// Server -- GRPC server meta data used in route calls
|
||||
type Server struct {
|
||||
DataDir string
|
||||
DB *psdb.DB
|
||||
pkey crypto.PrivateKey
|
||||
totalAllocated int64
|
||||
DataDir string
|
||||
DB *psdb.DB
|
||||
pkey crypto.PrivateKey
|
||||
totalAllocated int64
|
||||
totalBwAllocated int64
|
||||
}
|
||||
|
||||
// Initialize -- initializes a server struct
|
||||
@ -90,6 +92,7 @@ func Initialize(ctx context.Context, config Config, pkey crypto.PrivateKey) (*Se
|
||||
|
||||
// read the allocated disk space from the config file
|
||||
allocatedDiskSpace := config.AllocatedDiskSpace
|
||||
allocatedBandwidth := config.AllocatedBandwidth
|
||||
|
||||
// get the disk space details
|
||||
// The returned path ends in a slash only if it represents a root directory, such as "/" on Unix or `C:\` on Windows.
|
||||
@ -112,12 +115,23 @@ func Initialize(ctx context.Context, config Config, pkey crypto.PrivateKey) (*Se
|
||||
totalUsed = 0x00
|
||||
}
|
||||
|
||||
// get used bandwidth from the beginning of the month to till date
|
||||
usedBandwidth, err := db.GetTotalBandwidthBetween(getBeginningOfMonth(), time.Now())
|
||||
if err != nil {
|
||||
return nil, ServerError.Wrap(err)
|
||||
}
|
||||
if usedBandwidth > allocatedBandwidth {
|
||||
zap.S().Warnf("Exceed the allowed Bandwidth setting")
|
||||
} else {
|
||||
zap.S().Info("Remaining Bandwidth ", allocatedBandwidth-usedBandwidth)
|
||||
}
|
||||
|
||||
// check your hard drive is big enough
|
||||
// first time setup as a piece node server
|
||||
if (totalUsed == 0x00) && (freeDiskSpace < allocatedDiskSpace) {
|
||||
allocatedDiskSpace = freeDiskSpace
|
||||
zap.S().Warnf("Disk space is less than requested allocated space, allocating = %d Bytes", allocatedDiskSpace)
|
||||
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace}, nil
|
||||
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace, totalBwAllocated: allocatedBandwidth}, nil
|
||||
}
|
||||
|
||||
// on restarting the Piece node server, assuming already been working as a node
|
||||
@ -125,7 +139,7 @@ func Initialize(ctx context.Context, config Config, pkey crypto.PrivateKey) (*Se
|
||||
// before restarting
|
||||
if totalUsed >= allocatedDiskSpace {
|
||||
zap.S().Warnf("Used more space then allocated, allocating = %d Bytes", allocatedDiskSpace)
|
||||
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace}, nil
|
||||
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace, totalBwAllocated: allocatedBandwidth}, nil
|
||||
}
|
||||
|
||||
// the available diskspace is less than remaining allocated space,
|
||||
@ -133,10 +147,10 @@ func Initialize(ctx context.Context, config Config, pkey crypto.PrivateKey) (*Se
|
||||
if freeDiskSpace < (allocatedDiskSpace - totalUsed) {
|
||||
allocatedDiskSpace = freeDiskSpace
|
||||
zap.S().Warnf("Disk space is less than requested allocated space, allocating = %d Bytes", allocatedDiskSpace)
|
||||
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace}, nil
|
||||
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace, totalBwAllocated: allocatedBandwidth}, nil
|
||||
}
|
||||
|
||||
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace}, nil
|
||||
return &Server{DataDir: dataDir, DB: db, pkey: pkey, totalAllocated: allocatedDiskSpace, totalBwAllocated: allocatedBandwidth}, nil
|
||||
}
|
||||
|
||||
// Stop the piececstore node
|
||||
@ -186,7 +200,12 @@ func (s *Server) Stats(ctx context.Context, in *pb.StatsReq) (*pb.StatSummary, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pb.StatSummary{UsedSpace: totalUsed, AvailableSpace: (s.totalAllocated - totalUsed)}, nil
|
||||
totalUsedBandwidth, err := s.DB.GetTotalBandwidthBetween(getBeginningOfMonth(), time.Now())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &pb.StatSummary{UsedSpace: totalUsed, AvailableSpace: (s.totalAllocated - totalUsed), UsedBandwidth: totalUsedBandwidth, AvailableBandwidth: (s.totalBwAllocated - totalUsedBandwidth)}, nil
|
||||
}
|
||||
|
||||
// Delete -- Delete data by Id from piecestore
|
||||
@ -232,3 +251,9 @@ func (s *Server) verifySignature(ctx context.Context, ba *pb.RenterBandwidthAllo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getBeginningOfMonth() time.Time {
|
||||
t := time.Now()
|
||||
y, m, _ := t.Date()
|
||||
return time.Date(y, m, 1, 0, 0, 0, 0, time.Now().Location())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user