From 291deb901e322c0be464c10a42c1774dc80fab94 Mon Sep 17 00:00:00 2001 From: Gaius Date: Wed, 15 Nov 2023 10:45:50 +0800 Subject: [PATCH] feat: add optional to content for piece message Signed-off-by: Gaius --- Cargo.toml | 2 +- pkg/apis/common/v2/common.pb.go | 89 ++++++++++++----------- pkg/apis/common/v2/common.pb.validate.go | 48 ++++++------ pkg/apis/common/v2/common.proto | 4 +- proto/common.proto | 2 +- src/common.v2.rs | 4 +- src/descriptor.bin | Bin 76539 -> 76571 bytes 7 files changed, 73 insertions(+), 76 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f193ae4..00e4c73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dragonfly-api" -version = "2.0.48" +version = "2.0.49" authors = ["Gaius "] edition = "2021" license = "Apache-2.0" diff --git a/pkg/apis/common/v2/common.pb.go b/pkg/apis/common/v2/common.pb.go index d6f7826..e9eb8d8 100644 --- a/pkg/apis/common/v2/common.pb.go +++ b/pkg/apis/common/v2/common.pb.go @@ -1657,7 +1657,7 @@ type Piece struct { // Digest of the piece data, for example md5:xxx or sha256:yyy. Digest string `protobuf:"bytes,5,opt,name=digest,proto3" json:"digest,omitempty"` // Piece content. - Content []byte `protobuf:"bytes,6,opt,name=content,proto3" json:"content,omitempty"` + Content []byte `protobuf:"bytes,6,opt,name=content,proto3,oneof" json:"content,omitempty"` // Traffic type. TrafficType *TrafficType `protobuf:"varint,7,opt,name=traffic_type,json=trafficType,proto3,enum=common.v2.TrafficType,oneof" json:"traffic_type,omitempty"` // Downloading piece costs time. @@ -2080,30 +2080,30 @@ var file_pkg_apis_common_v2_common_proto_rawDesc = []byte{ 0x28, 0x03, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x22, 0x02, 0x28, 0x00, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x12, 0x1f, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x22, 0x02, 0x20, 0x00, 0x52, 0x06, 0x6c, 0x65, 0x6e, - 0x67, 0x74, 0x68, 0x22, 0x99, 0x04, 0x0a, 0x05, 0x50, 0x69, 0x65, 0x63, 0x65, 0x12, 0x1f, 0x0a, + 0x67, 0x74, 0x68, 0x22, 0xa5, 0x04, 0x0a, 0x05, 0x50, 0x69, 0x65, 0x63, 0x65, 0x12, 0x1f, 0x0a, 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, 0x2c, + 0x42, 0x04, 0x1a, 0x02, 0x28, 0x00, 0x52, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x29, 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, 0x48, 0x00, 0x52, - 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x06, - 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, - 0x04, 0x32, 0x02, 0x28, 0x00, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1f, 0x0a, - 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x32, 0x02, 0x20, 0x00, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x7d, - 0x0a, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x65, - 0xfa, 0x42, 0x62, 0x72, 0x60, 0x32, 0x5b, 0x5e, 0x28, 0x6d, 0x64, 0x35, 0x3a, 0x5b, 0x61, 0x2d, - 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x33, 0x32, 0x7d, 0x7c, 0x73, 0x68, 0x61, - 0x31, 0x3a, 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x34, 0x30, - 0x7d, 0x7c, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x3a, 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, - 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x36, 0x34, 0x7d, 0x7c, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x3a, - 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x31, 0x32, 0x38, 0x7d, - 0x29, 0x24, 0xd0, 0x01, 0x01, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, - 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x09, - 0xfa, 0x42, 0x06, 0x7a, 0x04, 0x10, 0x01, 0x70, 0x01, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x74, 0x12, 0x3e, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x5f, 0x74, 0x79, + 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x48, 0x00, 0x52, 0x08, 0x70, 0x61, + 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x06, 0x6f, 0x66, 0x66, + 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, 0x02, + 0x28, 0x00, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x1f, 0x0a, 0x06, 0x6c, 0x65, + 0x6e, 0x67, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x32, + 0x02, 0x20, 0x00, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x7d, 0x0a, 0x06, 0x64, + 0x69, 0x67, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x65, 0xfa, 0x42, 0x62, + 0x72, 0x60, 0x32, 0x5b, 0x5e, 0x28, 0x6d, 0x64, 0x35, 0x3a, 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, + 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x33, 0x32, 0x7d, 0x7c, 0x73, 0x68, 0x61, 0x31, 0x3a, 0x5b, + 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x34, 0x30, 0x7d, 0x7c, 0x73, + 0x68, 0x61, 0x32, 0x35, 0x36, 0x3a, 0x5b, 0x61, 0x2d, 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, + 0x5d, 0x7b, 0x36, 0x34, 0x7d, 0x7c, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x3a, 0x5b, 0x61, 0x2d, + 0x66, 0x41, 0x2d, 0x46, 0x30, 0x2d, 0x39, 0x5d, 0x7b, 0x31, 0x32, 0x38, 0x7d, 0x29, 0x24, 0xd0, + 0x01, 0x01, 0x52, 0x06, 0x64, 0x69, 0x67, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x07, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x07, 0xfa, 0x42, 0x04, + 0x7a, 0x02, 0x10, 0x01, 0x48, 0x01, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x88, + 0x01, 0x01, 0x12, 0x3e, 0x0a, 0x0c, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x2e, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, - 0x48, 0x01, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x88, + 0x48, 0x02, 0x52, 0x0b, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x12, 0x37, 0x0a, 0x04, 0x63, 0x6f, 0x73, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xfa, 0x42, 0x05, @@ -2112,29 +2112,30 @@ var file_pkg_apis_common_v2_common_proto_rawDesc = []byte{ 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xfa, 0x42, 0x05, 0xb2, 0x01, 0x02, 0x08, 0x01, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, - 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0f, - 0x0a, 0x0d, 0x5f, 0x74, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2a, - 0x43, 0x0a, 0x09, 0x53, 0x69, 0x7a, 0x65, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, - 0x4e, 0x4f, 0x52, 0x4d, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x4d, 0x41, 0x4c, - 0x4c, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x54, 0x49, 0x4e, 0x59, 0x10, 0x02, 0x12, 0x09, 0x0a, - 0x05, 0x45, 0x4d, 0x50, 0x54, 0x59, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x4e, 0x4b, 0x4e, - 0x4f, 0x57, 0x10, 0x04, 0x2a, 0x32, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x46, 0x44, 0x41, 0x45, 0x4d, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x0b, - 0x0a, 0x07, 0x44, 0x46, 0x43, 0x41, 0x43, 0x48, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x44, - 0x46, 0x53, 0x54, 0x4f, 0x52, 0x45, 0x10, 0x02, 0x2a, 0x42, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x66, - 0x66, 0x69, 0x63, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x41, 0x43, 0x4b, 0x5f, - 0x54, 0x4f, 0x5f, 0x53, 0x4f, 0x55, 0x52, 0x43, 0x45, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x52, - 0x45, 0x4d, 0x4f, 0x54, 0x45, 0x5f, 0x50, 0x45, 0x45, 0x52, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, - 0x4c, 0x4f, 0x43, 0x41, 0x4c, 0x5f, 0x50, 0x45, 0x45, 0x52, 0x10, 0x02, 0x2a, 0x5e, 0x0a, 0x08, - 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, - 0x4c, 0x30, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x31, 0x10, 0x01, - 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x32, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, - 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x33, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, - 0x4c, 0x34, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x35, 0x10, 0x05, - 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x36, 0x10, 0x06, 0x42, 0x29, 0x5a, 0x27, - 0x64, 0x37, 0x79, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6b, - 0x67, 0x2f, 0x61, 0x70, 0x69, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x32, - 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0a, + 0x0a, 0x08, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x42, 0x0f, 0x0a, 0x0d, 0x5f, 0x74, + 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x2a, 0x43, 0x0a, 0x09, 0x53, + 0x69, 0x7a, 0x65, 0x53, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x52, 0x4d, + 0x41, 0x4c, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x4d, 0x41, 0x4c, 0x4c, 0x10, 0x01, 0x12, + 0x08, 0x0a, 0x04, 0x54, 0x49, 0x4e, 0x59, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x4d, 0x50, + 0x54, 0x59, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x10, 0x04, + 0x2a, 0x32, 0x0a, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0c, 0x0a, 0x08, + 0x44, 0x46, 0x44, 0x41, 0x45, 0x4d, 0x4f, 0x4e, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x46, + 0x43, 0x41, 0x43, 0x48, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x46, 0x53, 0x54, 0x4f, + 0x52, 0x45, 0x10, 0x02, 0x2a, 0x42, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x66, 0x66, 0x69, 0x63, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x42, 0x41, 0x43, 0x4b, 0x5f, 0x54, 0x4f, 0x5f, 0x53, + 0x4f, 0x55, 0x52, 0x43, 0x45, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x52, 0x45, 0x4d, 0x4f, 0x54, + 0x45, 0x5f, 0x50, 0x45, 0x45, 0x52, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x4c, 0x4f, 0x43, 0x41, + 0x4c, 0x5f, 0x50, 0x45, 0x45, 0x52, 0x10, 0x02, 0x2a, 0x5e, 0x0a, 0x08, 0x50, 0x72, 0x69, 0x6f, + 0x72, 0x69, 0x74, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x30, 0x10, 0x00, + 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x31, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, + 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x32, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, + 0x4c, 0x33, 0x10, 0x03, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x34, 0x10, 0x04, + 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x35, 0x10, 0x05, 0x12, 0x0a, 0x0a, 0x06, + 0x4c, 0x45, 0x56, 0x45, 0x4c, 0x36, 0x10, 0x06, 0x42, 0x29, 0x5a, 0x27, 0x64, 0x37, 0x79, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x70, + 0x69, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x32, 0x3b, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/apis/common/v2/common.pb.validate.go b/pkg/apis/common/v2/common.pb.validate.go index 302043c..4b56702 100644 --- a/pkg/apis/common/v2/common.pb.validate.go +++ b/pkg/apis/common/v2/common.pb.validate.go @@ -2330,21 +2330,6 @@ func (m *Piece) validate(all bool) error { } - if len(m.GetContent()) > 0 { - - if len(m.GetContent()) < 1 { - err := PieceValidationError{ - field: "Content", - reason: "value length must be at least 1 bytes", - } - if !all { - return err - } - errors = append(errors, err) - } - - } - if m.GetCost() == nil { err := PieceValidationError{ field: "Cost", @@ -2369,19 +2354,30 @@ func (m *Piece) validate(all bool) error { if m.ParentId != nil { - if m.GetParentId() != "" { - - if utf8.RuneCountInString(m.GetParentId()) < 1 { - err := PieceValidationError{ - field: "ParentId", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) + if utf8.RuneCountInString(m.GetParentId()) < 1 { + err := PieceValidationError{ + field: "ParentId", + reason: "value length must be at least 1 runes", + } + if !all { + return err } + errors = append(errors, err) + } + + } + + if m.Content != nil { + if len(m.GetContent()) < 1 { + err := PieceValidationError{ + field: "Content", + reason: "value length must be at least 1 bytes", + } + if !all { + return err + } + errors = append(errors, err) } } diff --git a/pkg/apis/common/v2/common.proto b/pkg/apis/common/v2/common.proto index 6631b17..40d95b2 100644 --- a/pkg/apis/common/v2/common.proto +++ b/pkg/apis/common/v2/common.proto @@ -358,7 +358,7 @@ message Piece { // Piece number. int32 number = 1 [(validate.rules).int32.gte = 0]; // Parent peer id. - optional string parent_id = 2 [(validate.rules).string = {min_len: 1, ignore_empty: true}]; + optional string parent_id = 2 [(validate.rules).string = {min_len: 1}]; // Piece offset. uint64 offset = 3 [(validate.rules).uint64.gte = 0]; // Piece length. @@ -366,7 +366,7 @@ message Piece { // Digest of the piece data, for example md5:xxx or sha256:yyy. string digest = 5 [(validate.rules).string = {pattern: "^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128})$", ignore_empty: true}]; // Piece content. - bytes content = 6 [(validate.rules).bytes = {min_len: 1, ignore_empty: true}]; + optional bytes content = 6 [(validate.rules).bytes = {min_len: 1}]; // Traffic type. optional TrafficType traffic_type = 7; // Downloading piece costs time. diff --git a/proto/common.proto b/proto/common.proto index ebe1e93..81f9bfa 100644 --- a/proto/common.proto +++ b/proto/common.proto @@ -360,7 +360,7 @@ message Piece { // Digest of the piece data, for example md5:xxx or sha256:yyy. string digest = 5; // Piece content. - bytes content = 6; + optional bytes content = 6; // Traffic type. optional TrafficType traffic_type = 7; // Downloading piece costs time. diff --git a/src/common.v2.rs b/src/common.v2.rs index e1f7a45..d44e0fc 100644 --- a/src/common.v2.rs +++ b/src/common.v2.rs @@ -395,8 +395,8 @@ pub struct Piece { #[prost(string, tag = "5")] pub digest: ::prost::alloc::string::String, /// Piece content. - #[prost(bytes = "vec", tag = "6")] - pub content: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", optional, tag = "6")] + pub content: ::core::option::Option<::prost::alloc::vec::Vec>, /// Traffic type. #[prost(enumeration = "TrafficType", optional, tag = "7")] pub traffic_type: ::core::option::Option, diff --git a/src/descriptor.bin b/src/descriptor.bin index fb8c6a70c6f3ec82bdfb59c97aabfdbd0a87e0ac..b6f80ad5e015f44bccac63a8c3b086093fcf3102 100644 GIT binary patch delta 152 zcmex;m1XudmJQ3anWjzKyh7VZfbs9-+t%H3vRv%R`FSO&c_k8T3XB>&9*jXSfeuE- z$@Mn+j7*c)+jMesadE^$Rc}Eiy5QrP?T)bSYEZj`2 btROD80F28B;tEQ@xXd7~w9MxI(wwaTLS-ma delta 120 zcmbPzjpg@MmJQ3anZ8Zkyh7VZfbq@b+t%HZ5?t)b`FSO&c_k8T3XB>&K``#*78`v= z#>rc3IyZaTDlszd-kf9i#f(v8a$>2JDytC7D<&p(E?zEH7H%e1Mi7^SAI4<{afO68 JuP@En3IMZYBJ}_O