Skip to content

Commit 7d30c73

Browse files
committed
feat: update message protobuf to support new message types
1 parent aa1c635 commit 7d30c73

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/types/message/message.proto.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,18 @@
55
module.exports = `
66
message Message {
77
message Wantlist {
8+
enum WantType {
9+
Block = 0;
10+
Have = 1;
11+
}
12+
813
message Entry {
914
// changed from string to bytes, it makes a difference in JavaScript
1015
optional bytes block = 1; // the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0)
1116
optional int32 priority = 2; // the priority (normalized). default to 1
1217
optional bool cancel = 3; // whether this revokes an entry
18+
WantType want_type = 4; // Note: defaults to enum 0, ie Block
19+
bool send_dont_have = 5; // Note: defaults to false
1320
}
1421
1522
repeated Entry entries = 1; // a list of wantlist entries
@@ -21,8 +28,19 @@ module.exports = `
2128
optional bytes data = 2;
2229
}
2330
31+
enum BlockPresenceType {
32+
Have = 0;
33+
DontHave = 1;
34+
}
35+
message BlockPresence {
36+
bytes cid = 1;
37+
BlockPresenceType type = 2;
38+
}
39+
2440
optional Wantlist wantlist = 1;
2541
repeated bytes blocks = 2; // used to send Blocks in bitswap 1.0.0
2642
repeated Block payload = 3; // used to send Blocks in bitswap 1.1.0
43+
repeated BlockPresence blockPresences = 4;
44+
int32 PendingBytes = 5;
2745
}
2846
`

test/types/message.spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ describe('BitswapMessage', () => {
3535
expect(pbm.Message.decode(serialized).wantlist.entries[0]).to.be.eql({
3636
block: cid.buffer,
3737
priority: 1,
38-
cancel: false
38+
cancel: false,
39+
send_dont_have: false,
40+
want_type: pbm.Message.Wantlist.WantType.Block
3941
})
4042
})
4143

0 commit comments

Comments
 (0)