Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

update gogo protobuf #2

Merged
merged 2 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gx/lastpubver
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.4: QmaYxvpkdEd5anuSzWiivJdeZV1W1NYW52xJQB1khSqH1b
1.0.5: QmerEhJuCXvrZoAqaxXHNbjtk6UgbGTSiAe4J3VGzgx61E
17 changes: 8 additions & 9 deletions message/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
blocks "github.com/ipfs/go-block-format"

ggio "github.com/gogo/protobuf/io"
proto "github.com/gogo/protobuf/proto"
cid "github.com/ipfs/go-cid"
inet "github.com/libp2p/go-libp2p-net"
)
Expand Down Expand Up @@ -185,12 +184,12 @@ func (m *impl) ToProtoV0() *pb.Message {
pbm.Wantlist.Entries = make([]*pb.Message_Wantlist_Entry, 0, len(m.wantlist))
for _, e := range m.wantlist {
pbm.Wantlist.Entries = append(pbm.Wantlist.Entries, &pb.Message_Wantlist_Entry{
Block: proto.String(e.Cid.KeyString()),
Priority: proto.Int32(int32(e.Priority)),
Cancel: proto.Bool(e.Cancel),
Block: e.Cid.Bytes(),
Priority: int32(e.Priority),
Cancel: e.Cancel,
})
}
pbm.Wantlist.Full = proto.Bool(m.full)
pbm.Wantlist.Full = m.full

blocks := m.Blocks()
pbm.Blocks = make([][]byte, 0, len(blocks))
Expand All @@ -206,12 +205,12 @@ func (m *impl) ToProtoV1() *pb.Message {
pbm.Wantlist.Entries = make([]*pb.Message_Wantlist_Entry, 0, len(m.wantlist))
for _, e := range m.wantlist {
pbm.Wantlist.Entries = append(pbm.Wantlist.Entries, &pb.Message_Wantlist_Entry{
Block: proto.String(e.Cid.KeyString()),
Priority: proto.Int32(int32(e.Priority)),
Cancel: proto.Bool(e.Cancel),
Block: e.Cid.Bytes(),
Priority: int32(e.Priority),
Cancel: e.Cancel,
})
}
pbm.Wantlist.Full = proto.Bool(m.full)
pbm.Wantlist.Full = m.full

blocks := m.Blocks()
pbm.Payload = make([]*pb.Message_Block, 0, len(blocks))
Expand Down
5 changes: 2 additions & 3 deletions message/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

pb "github.com/ipfs/go-bitswap/message/pb"

proto "github.com/gogo/protobuf/proto"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
u "github.com/ipfs/go-ipfs-util"
Expand All @@ -31,7 +30,7 @@ func TestNewMessageFromProto(t *testing.T) {
protoMessage := new(pb.Message)
protoMessage.Wantlist = new(pb.Message_Wantlist)
protoMessage.Wantlist.Entries = []*pb.Message_Wantlist_Entry{
{Block: proto.String(str.KeyString())},
{Block: str.Bytes()},
}
if !wantlistContains(protoMessage.Wantlist, str) {
t.Fail()
Expand Down Expand Up @@ -166,7 +165,7 @@ func TestToAndFromNetMessage(t *testing.T) {

func wantlistContains(wantlist *pb.Message_Wantlist, c *cid.Cid) bool {
for _, e := range wantlist.GetEntries() {
if e.GetBlock() == c.KeyString() {
if bytes.Equal(e.GetBlock(), c.Bytes()) {
return true
}
}
Expand Down
13 changes: 8 additions & 5 deletions message/pb/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# TODO(brian): add proto tasks
all: message.pb.go
PB = $(wildcard *.proto)
GO = $(PB:.proto=.pb.go)

message.pb.go: message.proto
protoc --gogo_out=. --proto_path=../../../../../:/usr/local/opt/protobuf/include:. $<
all: $(GO)

%.pb.go: %.proto
protoc --proto_path=$(GOPATH)/src:. --gogofast_out=. $<

clean:
rm message.pb.go
rm -f *.pb.go
rm -f *.go
8 changes: 0 additions & 8 deletions message/pb/Rules.mk

This file was deleted.

Loading