Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-bitswap
Commits
18c43be9
Commit
18c43be9
authored
Aug 07, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update gogo protobuf
and switch to proto3
parent
3cef6b50
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1065 additions
and
70 deletions
+1065
-70
message/message.go
message/message.go
+8
-9
message/message_test.go
message/message_test.go
+2
-3
message/pb/Makefile
message/pb/Makefile
+8
-5
message/pb/Rules.mk
message/pb/Rules.mk
+0
-8
message/pb/message.pb.go
message/pb/message.pb.go
+1035
-35
message/pb/message.proto
message/pb/message.proto
+11
-9
package.json
package.json
+1
-1
No files found.
message/message.go
View file @
18c43be9
...
...
@@ -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"
)
...
...
@@ -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
))
...
...
@@ -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
))
...
...
message/message_test.go
View file @
18c43be9
...
...
@@ -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"
...
...
@@ -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
()
...
...
@@ -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
}
}
...
...
message/pb/Makefile
View file @
18c43be9
# 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
message/pb/Rules.mk
deleted
100644 → 0
View file @
3cef6b50
include
mk/header.mk
PB_$(d)
=
$(
wildcard
$(d)
/
*
.proto
)
TGTS_$(d)
=
$
(
PB_
$(d)
:.proto
=
.pb.go
)
#DEPS_GO += $(TGTS_$(d))
include
mk/footer.mk
message/pb/message.pb.go
View file @
18c43be9
This diff is collapsed.
Click to expand it.
message/pb/message.proto
View file @
18c43be9
syntax
=
"proto3"
;
package
bitswap
.
message.pb
;
message
Message
{
...
...
@@ -5,21 +7,21 @@ message Message {
message
Wantlist
{
message
Entry
{
optional
string
block
=
1
;
// the block cid (cidV0 in bitswap 1.0.0, cidV1 in bitswap 1.1.0)
optional
int32
priority
=
2
;
// the priority (normalized). default to 1
optional
bool
cancel
=
3
;
// whether this revokes an entry
}
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
bool
cancel
=
3
;
// whether this revokes an entry
}
repeated
Entry
entries
=
1
;
// a list of wantlist entries
optional
bool
full
=
2
;
// whether this is the full wantlist. default to false
repeated
Entry
entries
=
1
;
// a list of wantlist entries
bool
full
=
2
;
// whether this is the full wantlist. default to false
}
message
Block
{
optional
bytes
prefix
=
1
;
// CID prefix (cid version, multicodec and multihash prefix (type + length)
optional
bytes
data
=
2
;
bytes
prefix
=
1
;
// CID prefix (cid version, multicodec and multihash prefix (type + length)
bytes
data
=
2
;
}
optional
Wantlist
wantlist
=
1
;
Wantlist
wantlist
=
1
;
repeated
bytes
blocks
=
2
;
// used to send Blocks in bitswap 1.0.0
repeated
Block
payload
=
3
;
// used to send Blocks in bitswap 1.1.0
}
package.json
View file @
18c43be9
...
...
@@ -39,7 +39,7 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
Z4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV
"
,
"hash"
:
"Qm
dxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8
"
,
"name"
:
"gogo-protobuf"
,
"version"
:
"0.0.0"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment