Skip to content

Commit

Permalink
feat: change length from int to uint (#220)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Nov 20, 2023
1 parent 2840dfe commit 667eb73
Show file tree
Hide file tree
Showing 17 changed files with 868 additions and 989 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.54"
version = "2.0.55"
authors = ["Gaius <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
Expand Down
622 changes: 309 additions & 313 deletions pkg/apis/common/v2/common.pb.go

Large diffs are not rendered by default.

88 changes: 8 additions & 80 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.

20 changes: 10 additions & 10 deletions pkg/apis/common/v2/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,19 @@ message Task {
// Task request headers.
map<string, string> header = 8;
// Task piece length.
int32 piece_length = 9 [(validate.rules).int32.gte = 1];
uint32 piece_length = 9 [(validate.rules).uint32.gte = 1];
// Task content length.
int64 content_length = 10 [(validate.rules).int64.gte = 1];
uint64 content_length = 10;
// Task piece count.
int32 piece_count = 11 [(validate.rules).int32.gte = 0];
uint32 piece_count = 11;
// Task size scope.
SizeScope size_scope = 12;
// Pieces of task.
repeated Piece pieces = 13 [(validate.rules).repeated = {min_items: 1, ignore_empty: true}];
// Task state.
string state = 14 [(validate.rules).string.min_len = 1];
// Task peer count.
int32 peer_count = 15 [(validate.rules).int32.gte = 0];
uint32 peer_count = 15;
// Task contains available peer.
bool hasAvailablePeer = 16;
// Task create time.
Expand Down Expand Up @@ -334,7 +334,7 @@ message Download {
// Task request headers.
map<string, string> header = 9;
// Task piece length.
int32 piece_length = 10 [(validate.rules).int32.gte = 1];
uint32 piece_length = 10 [(validate.rules).uint32.gte = 1];
// File path to be exported.
string output_path = 11 [(validate.rules).string = {min_len: 1, ignore_empty: true}];
// Download timeout.
Expand All @@ -348,21 +348,21 @@ message Download {
// Range represents download range.
message Range {
// Start of range.
int64 start = 1 [(validate.rules).int64.gte = 0];
uint64 start = 1;
// Length of range.
int64 length = 2 [(validate.rules).int64.gt = 0];
uint64 length = 2;
}

// Piece represents information of piece.
message Piece {
// Piece number.
int32 number = 1 [(validate.rules).int32.gte = 0];
uint32 number = 1;
// Parent peer id.
optional string parent_id = 2 [(validate.rules).string = {min_len: 1}];
// Piece offset.
uint64 offset = 3 [(validate.rules).uint64.gte = 0];
uint64 offset = 3;
// Piece length.
uint64 length = 4 [(validate.rules).uint64.gt = 0];
uint64 length = 4;
// 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.
Expand Down
Loading

0 comments on commit 667eb73

Please sign in to comment.