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
824a185f
Commit
824a185f
authored
Oct 27, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style(bitswap/message) rename struct
so there's one less name to think about
parent
a68d9310
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
message/message.go
message/message.go
+8
-8
No files found.
message/message.go
View file @
824a185f
...
...
@@ -27,13 +27,13 @@ type Exportable interface {
}
// message wraps a proto message for convenience
type
message
struct
{
type
impl
struct
{
wantlist
map
[
u
.
Key
]
struct
{}
blocks
[]
blocks
.
Block
}
func
New
()
BitSwapMessage
{
return
&
message
{
return
&
impl
{
wantlist
:
make
(
map
[
u
.
Key
]
struct
{}),
}
}
...
...
@@ -51,7 +51,7 @@ func newMessageFromProto(pbm pb.Message) BitSwapMessage {
}
// TODO(brian): convert these into keys
func
(
m
*
message
)
Wantlist
()
[]
u
.
Key
{
func
(
m
*
impl
)
Wantlist
()
[]
u
.
Key
{
wl
:=
make
([]
u
.
Key
,
0
)
for
k
,
_
:=
range
m
.
wantlist
{
wl
=
append
(
wl
,
k
)
...
...
@@ -60,15 +60,15 @@ func (m *message) Wantlist() []u.Key {
}
// TODO(brian): convert these into blocks
func
(
m
*
message
)
Blocks
()
[]
blocks
.
Block
{
func
(
m
*
impl
)
Blocks
()
[]
blocks
.
Block
{
return
m
.
blocks
}
func
(
m
*
message
)
AddWanted
(
k
u
.
Key
)
{
func
(
m
*
impl
)
AddWanted
(
k
u
.
Key
)
{
m
.
wantlist
[
k
]
=
struct
{}{}
}
func
(
m
*
message
)
AppendBlock
(
b
blocks
.
Block
)
{
func
(
m
*
impl
)
AppendBlock
(
b
blocks
.
Block
)
{
m
.
blocks
=
append
(
m
.
blocks
,
b
)
}
...
...
@@ -81,7 +81,7 @@ func FromNet(nmsg netmsg.NetMessage) (BitSwapMessage, error) {
return
m
,
nil
}
func
(
m
*
message
)
ToProto
()
*
pb
.
Message
{
func
(
m
*
impl
)
ToProto
()
*
pb
.
Message
{
pb
:=
new
(
pb
.
Message
)
for
_
,
k
:=
range
m
.
Wantlist
()
{
pb
.
Wantlist
=
append
(
pb
.
Wantlist
,
string
(
k
))
...
...
@@ -92,6 +92,6 @@ func (m *message) ToProto() *pb.Message {
return
pb
}
func
(
m
*
message
)
ToNet
(
p
peer
.
Peer
)
(
nm
.
NetMessage
,
error
)
{
func
(
m
*
impl
)
ToNet
(
p
peer
.
Peer
)
(
nm
.
NetMessage
,
error
)
{
return
nm
.
FromObject
(
p
,
m
.
ToProto
())
}
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