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
96e4204f
Commit
96e4204f
authored
Dec 01, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
switch over to using sendMessage vs sendRequest
parent
27193bde
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
22 deletions
+5
-22
bitswap.go
bitswap.go
+3
-7
network/ipfs_impl.go
network/ipfs_impl.go
+2
-15
No files found.
bitswap.go
View file @
96e4204f
...
...
@@ -151,6 +151,7 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.Peer) e
message
.
AddWanted
(
wanted
)
}
for
peerToQuery
:=
range
peers
{
log
.
Debug
(
"sending query to: %s"
,
peerToQuery
)
log
.
Event
(
ctx
,
"PeerToQuery"
,
peerToQuery
)
go
func
(
p
peer
.
Peer
)
{
...
...
@@ -161,20 +162,15 @@ func (bs *bitswap) sendWantListTo(ctx context.Context, peers <-chan peer.Peer) e
return
}
response
,
err
:
=
bs
.
sender
.
Send
Request
(
ctx
,
p
,
message
)
err
=
bs
.
sender
.
Send
Message
(
ctx
,
p
,
message
)
if
err
!=
nil
{
log
.
Errorf
(
"Error sender.Send
Request
(%s) = %s"
,
p
,
err
)
log
.
Errorf
(
"Error sender.Send
Message
(%s) = %s"
,
p
,
err
)
return
}
// FIXME ensure accounting is handled correctly when
// communication fails. May require slightly different API to
// get better guarantees. May need shared sequence numbers.
bs
.
strategy
.
MessageSent
(
p
,
message
)
if
response
==
nil
{
return
}
bs
.
ReceiveMessage
(
ctx
,
p
,
response
)
}(
peerToQuery
)
}
return
nil
...
...
network/ipfs_impl.go
View file @
96e4204f
...
...
@@ -48,21 +48,8 @@ func (bsnet *impl) HandleMessage(
return
nil
}
p
,
bsmsg
:=
bsnet
.
receiver
.
ReceiveMessage
(
ctx
,
incoming
.
Peer
(),
received
)
// TODO(brian): put this in a helper function
if
bsmsg
==
nil
||
p
==
nil
{
return
nil
}
outgoing
,
err
:=
bsmsg
.
ToNet
(
p
)
if
err
!=
nil
{
go
bsnet
.
receiver
.
ReceiveError
(
err
)
return
nil
}
log
.
Debugf
(
"Message size: %d"
,
len
(
outgoing
.
Data
()))
return
outgoing
bsnet
.
receiver
.
ReceiveMessage
(
ctx
,
incoming
.
Peer
(),
received
)
return
nil
}
func
(
bsnet
*
impl
)
DialPeer
(
ctx
context
.
Context
,
p
peer
.
Peer
)
error
{
...
...
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