Skip to content

Commit 433d0b5

Browse files
Merge pull request ipfs#3461 from ipfs/fix/bitswap-message-marshal
bitswap: add wantlist fullness to protobuf messages
2 parents ac16ac5 + 6f8dd03 commit 433d0b5

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

exchange/bitswap/message/message.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func (m *impl) ToProtoV0() *pb.Message {
189189
Cancel: proto.Bool(e.Cancel),
190190
})
191191
}
192+
pbm.Wantlist.Full = proto.Bool(m.full)
192193
for _, b := range m.Blocks() {
193194
pbm.Blocks = append(pbm.Blocks, b.RawData())
194195
}
@@ -205,6 +206,7 @@ func (m *impl) ToProtoV1() *pb.Message {
205206
Cancel: proto.Bool(e.Cancel),
206207
})
207208
}
209+
pbm.Wantlist.Full = proto.Bool(m.full)
208210
for _, b := range m.Blocks() {
209211
blk := &pb.Message_Block{
210212
Data: b.RawData(),

exchange/bitswap/message/message_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ func TestToNetFromNetPreservesWantList(t *testing.T) {
118118
t.Fatal(err)
119119
}
120120

121+
if !copied.Full() {
122+
t.Fatal("fullness attribute got dropped on marshal")
123+
}
124+
121125
keys := make(map[string]bool)
122126
for _, k := range copied.Wantlist() {
123127
keys[k.Cid.KeyString()] = true

0 commit comments

Comments
 (0)