Skip to content

Commit

Permalink
feat: add optional to content for piece message
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi committed Nov 15, 2023
1 parent b53f8ac commit 291deb9
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 76 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dragonfly-api"
version = "2.0.48"
version = "2.0.49"
authors = ["Gaius <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
89 changes: 45 additions & 44 deletions pkg/apis/common/v2/common.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 22 additions & 26 deletions pkg/apis/common/v2/common.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/apis/common/v2/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,15 @@ 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.
uint64 length = 4 [(validate.rules).uint64.gt = 0];
// 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.
Expand Down
2 changes: 1 addition & 1 deletion proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/common.v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>,
#[prost(bytes = "vec", optional, tag = "6")]
pub content: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
/// Traffic type.
#[prost(enumeration = "TrafficType", optional, tag = "7")]
pub traffic_type: ::core::option::Option<i32>,
Expand Down
Binary file modified src/descriptor.bin
Binary file not shown.

0 comments on commit 291deb9

Please sign in to comment.