Cleanup protobuf for use with protobufserialization

This commit is contained in:
Mark Spanbroek 2021-01-21 13:48:09 +01:00 committed by markspanbroek
parent 8f4a7d796f
commit 216317d4f5

View File

@ -2,25 +2,23 @@ syntax = "proto3";
package bitswap.message.pb; package bitswap.message.pb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
message Message { message Message {
message Wantlist { message Wantlist {
enum WantType { enum WantType {
Block = 0; wantBlock = 0;
Have = 1; wantHave = 1;
} }
message Entry { message Entry {
bytes block = 1 [(gogoproto.customtype) = "Cid", (gogoproto.nullable) = false]; // the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0) bytes block = 1; // the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0)
int32 priority = 2; // the priority (normalized). default to 1 int32 priority = 2; // the priority (normalized). default to 1
bool cancel = 3; // whether this revokes an entry bool cancel = 3; // whether this revokes an entry
WantType wantType = 4; // Note: defaults to enum 0, ie Block WantType wantType = 4; // Note: defaults to enum 0, ie Block
bool sendDontHave = 5; // Note: defaults to false bool sendDontHave = 5; // Note: defaults to false
} }
repeated Entry entries = 1 [(gogoproto.nullable) = false]; // a list of wantlist entries repeated Entry entries = 1; // a list of wantlist entries
bool full = 2; // whether this is the full wantlist. default to false bool full = 2; // whether this is the full wantlist. default to false
} }
@ -30,17 +28,17 @@ message Message {
} }
enum BlockPresenceType { enum BlockPresenceType {
Have = 0; presenceHave = 0;
DontHave = 1; presenceDontHave = 1;
} }
message BlockPresence { message BlockPresence {
bytes cid = 1 [(gogoproto.customtype) = "Cid", (gogoproto.nullable) = false]; bytes cid = 1;
BlockPresenceType type = 2; BlockPresenceType type = 2;
} }
Wantlist wantlist = 1 [(gogoproto.nullable) = false]; Wantlist wantlist = 1;
repeated bytes blocks = 2; // used to send Blocks in bitswap 1.0.0 repeated bytes blocks = 2; // used to send Blocks in bitswap 1.0.0
repeated Block payload = 3 [(gogoproto.nullable) = false]; // used to send Blocks in bitswap 1.1.0 repeated Block payload = 3; // used to send Blocks in bitswap 1.1.0
repeated BlockPresence blockPresences = 4 [(gogoproto.nullable) = false]; repeated BlockPresence blockPresences = 4;
int32 pendingBytes = 5; int32 pendingBytes = 5;
} }