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
0f64cfa8
Unverified
Commit
0f64cfa8
authored
Aug 09, 2018
by
Steven Allen
Committed by
GitHub
Aug 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2 from ipfs/feat/protobuf
update gogo protobuf
parents
3cef6b50
ec9a1097
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1067 additions
and
72 deletions
+1067
-72
.gx/lastpubver
.gx/lastpubver
+1
-1
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
+2
-2
No files found.
.gx/lastpubver
View file @
0f64cfa8
1.0.
4
: Qm
aYxvpkdEd5anuSzWiivJdeZV1W1NYW52xJQB1khSqH1b
1.0.
5
: Qm
erEhJuCXvrZoAqaxXHNbjtk6UgbGTSiAe4J3VGzgx61E
message/message.go
View file @
0f64cfa8
...
...
@@ -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 @
0f64cfa8
...
...
@@ -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 @
0f64cfa8
# 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 @
0f64cfa8
This diff is collapsed.
Click to expand it.
message/pb/message.proto
View file @
0f64cfa8
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 @
0f64cfa8
...
...
@@ -39,7 +39,7 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
Z4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV
"
,
"hash"
:
"Qm
dxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8
"
,
"name"
:
"gogo-protobuf"
,
"version"
:
"0.0.0"
},
...
...
@@ -97,6 +97,6 @@
"license"
:
""
,
"name"
:
"go-bitswap"
,
"releaseCmd"
:
"git commit -a -m
\"
gx publish $VERSION
\"
"
,
"version"
:
"1.0.
4
"
"version"
:
"1.0.
5
"
}
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