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-unixfs
Commits
21639564
Commit
21639564
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(bitswap:msg) impl FromSwarm method
parent
70999886
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
bitswap/message.go
bitswap/message.go
+11
-0
No files found.
bitswap/message.go
View file @
21639564
package
bitswap
import
(
proto
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
blocks
"github.com/jbenet/go-ipfs/blocks"
nm
"github.com/jbenet/go-ipfs/net/message"
swarm
"github.com/jbenet/go-ipfs/net/swarm"
...
...
@@ -41,6 +43,15 @@ func (m *message) AppendBlock(b *blocks.Block) {
m
.
pb
.
Blocks
=
append
(
m
.
pb
.
Blocks
,
b
.
Data
)
}
func
FromSwarm
(
sms
swarm
.
Message
)
(
BitSwapMessage
,
error
)
{
var
protoMsg
PBMessage
err
:=
proto
.
Unmarshal
(
sms
.
Data
,
&
protoMsg
)
if
err
!=
nil
{
return
nil
,
err
}
return
newMessageFromProto
(
protoMsg
),
nil
}
func
(
m
*
message
)
ToProto
()
*
PBMessage
{
cp
:=
m
.
pb
return
&
cp
...
...
This diff is collapsed.
Click to expand it.
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