From 11a152f2948e5b9111e710f50b29c13baf17a2db Mon Sep 17 00:00:00 2001 From: Gaius Date: Mon, 20 Feb 2023 16:00:17 +0800 Subject: [PATCH] feat: change piece number type from uint32 to int32 (#72) Signed-off-by: Gaius --- pkg/apis/common/v2/common.pb.go | 8 ++++---- pkg/apis/common/v2/common.proto | 2 +- proto/common.proto | 2 +- src/common.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/apis/common/v2/common.pb.go b/pkg/apis/common/v2/common.pb.go index cee37bd..4b91a44 100644 --- a/pkg/apis/common/v2/common.pb.go +++ b/pkg/apis/common/v2/common.pb.go @@ -970,7 +970,7 @@ type Piece struct { unknownFields protoimpl.UnknownFields // Piece number. - Number uint32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` + Number int32 `protobuf:"varint,1,opt,name=number,proto3" json:"number,omitempty"` // Parent peer id. ParentId string `protobuf:"bytes,2,opt,name=parent_id,json=parentId,proto3" json:"parent_id,omitempty"` // Piece offset. @@ -1019,7 +1019,7 @@ func (*Piece) Descriptor() ([]byte, []int) { return file_pkg_apis_common_v2_common_proto_rawDescGZIP(), []int{5} } -func (x *Piece) GetNumber() uint32 { +func (x *Piece) GetNumber() int32 { if x != nil { return x.Number } @@ -1310,8 +1310,8 @@ var file_pkg_apis_common_v2_common_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x8d, 0x03, 0x0a, 0x05, 0x50, 0x69, 0x65, 0x63, 0x65, 0x12, 0x1f, 0x0a, - 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x2a, 0x02, 0x28, 0x00, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x27, + 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x42, 0x07, 0xfa, + 0x42, 0x04, 0x1a, 0x02, 0x28, 0x00, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0a, 0xfa, 0x42, 0x07, 0x72, 0x05, 0x10, 0x01, 0xd0, 0x01, 0x01, 0x52, 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, diff --git a/pkg/apis/common/v2/common.proto b/pkg/apis/common/v2/common.proto index 42f9768..525cc8a 100644 --- a/pkg/apis/common/v2/common.proto +++ b/pkg/apis/common/v2/common.proto @@ -232,7 +232,7 @@ message Download { // Piece represents information of piece. message Piece { // Piece number. - uint32 number = 1 [(validate.rules).uint32.gte = 0]; + int32 number = 1 [(validate.rules).int32.gte = 0]; // Parent peer id. string parent_id = 2 [(validate.rules).string = {min_len: 1, ignore_empty: true}]; // Piece offset. diff --git a/proto/common.proto b/proto/common.proto index b0280b7..6a6e9bf 100644 --- a/proto/common.proto +++ b/proto/common.proto @@ -229,7 +229,7 @@ message Download { // Piece represents information of piece. message Piece { // Piece number. - uint32 number = 1; + int32 number = 1; // Parent peer id. string parent_id = 2; // Piece offset. diff --git a/src/common.rs b/src/common.rs index 6aa8d82..547ce3b 100644 --- a/src/common.rs +++ b/src/common.rs @@ -193,8 +193,8 @@ pub struct Download { #[derive(Clone, PartialEq, ::prost::Message)] pub struct Piece { /// Piece number. - #[prost(uint32, tag = "1")] - pub number: u32, + #[prost(int32, tag = "1")] + pub number: i32, /// Parent peer id. #[prost(string, tag = "2")] pub parent_id: ::prost::alloc::string::String,