From 6f8dd03e07d17ef97fa49255f64a3bd6801338b0 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Fri, 2 Dec 2016 14:15:24 -0800 Subject: [PATCH] bitswap: add wantlist fullness to protobuf messages License: MIT Signed-off-by: Jeromy --- exchange/bitswap/message/message.go | 2 ++ exchange/bitswap/message/message_test.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/exchange/bitswap/message/message.go b/exchange/bitswap/message/message.go index 41ae59bf04d..ad7177f0261 100644 --- a/exchange/bitswap/message/message.go +++ b/exchange/bitswap/message/message.go @@ -189,6 +189,7 @@ func (m *impl) ToProtoV0() *pb.Message { Cancel: proto.Bool(e.Cancel), }) } + pbm.Wantlist.Full = proto.Bool(m.full) for _, b := range m.Blocks() { pbm.Blocks = append(pbm.Blocks, b.RawData()) } @@ -205,6 +206,7 @@ func (m *impl) ToProtoV1() *pb.Message { Cancel: proto.Bool(e.Cancel), }) } + pbm.Wantlist.Full = proto.Bool(m.full) for _, b := range m.Blocks() { blk := &pb.Message_Block{ Data: b.RawData(), diff --git a/exchange/bitswap/message/message_test.go b/exchange/bitswap/message/message_test.go index 00740b42416..add64878f0e 100644 --- a/exchange/bitswap/message/message_test.go +++ b/exchange/bitswap/message/message_test.go @@ -118,6 +118,10 @@ func TestToNetFromNetPreservesWantList(t *testing.T) { t.Fatal(err) } + if !copied.Full() { + t.Fatal("fullness attribute got dropped on marshal") + } + keys := make(map[string]bool) for _, k := range copied.Wantlist() { keys[k.Cid.KeyString()] = true