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
1f178a6f
Commit
1f178a6f
authored
May 06, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address comments from CR
parent
b9fa4eed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
9 deletions
+17
-9
bitswap.go
bitswap.go
+17
-9
No files found.
bitswap.go
View file @
1f178a6f
...
...
@@ -349,7 +349,8 @@ func (bs *Bitswap) ReceiveMessage(ctx context.Context, p peer.ID, incoming bsmsg
keys
=
append
(
keys
,
block
.
Key
())
}
return
bs
.
cancelBlocks
(
ctx
,
keys
)
bs
.
cancelBlocks
(
ctx
,
keys
)
return
nil
}
// Connected/Disconnected warns bitswap about peer connections
...
...
@@ -369,9 +370,9 @@ func (bs *Bitswap) PeerDisconnected(p peer.ID) {
bs
.
engine
.
PeerDisconnected
(
p
)
}
func
(
bs
*
Bitswap
)
cancelBlocks
(
ctx
context
.
Context
,
bkeys
[]
u
.
Key
)
error
{
func
(
bs
*
Bitswap
)
cancelBlocks
(
ctx
context
.
Context
,
bkeys
[]
u
.
Key
)
{
if
len
(
bkeys
)
<
1
{
return
nil
return
}
message
:=
bsmsg
.
New
()
message
.
SetFull
(
false
)
...
...
@@ -379,14 +380,21 @@ func (bs *Bitswap) cancelBlocks(ctx context.Context, bkeys []u.Key) error {
log
.
Debug
(
"cancel block: %s"
,
k
)
message
.
Cancel
(
k
)
}
wg
:=
sync
.
WaitGroup
{}
for
_
,
p
:=
range
bs
.
engine
.
Peers
()
{
err
:=
bs
.
send
(
ctx
,
p
,
message
)
if
err
!=
nil
{
log
.
Debugf
(
"Error sending message: %s"
,
err
)
return
err
}
wg
.
Add
(
1
)
go
func
(
p
peer
.
ID
)
{
defer
wg
.
Done
()
err
:=
bs
.
send
(
ctx
,
p
,
message
)
if
err
!=
nil
{
log
.
Warningf
(
"Error sending message: %s"
,
err
)
return
}
}(
p
)
}
return
nil
wg
.
Wait
()
return
}
func
(
bs
*
Bitswap
)
wantNewBlocks
(
ctx
context
.
Context
,
bkeys
[]
u
.
Key
)
{
...
...
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