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
33d8110e
Commit
33d8110e
authored
Dec 16, 2014
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
Dec 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: avoid loop reuse
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
9069a8aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
bitswap.go
bitswap.go
+4
-2
No files found.
bitswap.go
View file @
33d8110e
...
@@ -309,14 +309,16 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.Peer, incoming bsm
...
@@ -309,14 +309,16 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.Peer, incoming bsm
// TODO: this is bad, and could be easily abused.
// TODO: this is bad, and could be easily abused.
// Should only track *useful* messages in ledger
// Should only track *useful* messages in ledger
var
blkeys
[]
u
.
Key
for
_
,
block
:=
range
incoming
.
Blocks
()
{
for
_
,
block
:=
range
incoming
.
Blocks
()
{
blkeys
=
append
(
blkeys
,
block
.
Key
())
hasBlockCtx
,
_
:=
context
.
WithTimeout
(
ctx
,
hasBlockTimeout
)
hasBlockCtx
,
_
:=
context
.
WithTimeout
(
ctx
,
hasBlockTimeout
)
if
err
:=
bs
.
HasBlock
(
hasBlockCtx
,
block
);
err
!=
nil
{
if
err
:=
bs
.
HasBlock
(
hasBlockCtx
,
block
);
err
!=
nil
{
log
.
Error
(
err
)
log
.
Error
(
err
)
}
}
}
}
var
blkeys
[]
u
.
Key
for
_
,
block
:=
range
incoming
.
Blocks
()
{
blkeys
=
append
(
blkeys
,
block
.
Key
())
}
if
len
(
blkeys
)
>
0
{
if
len
(
blkeys
)
>
0
{
bs
.
cancelBlocks
(
ctx
,
blkeys
)
bs
.
cancelBlocks
(
ctx
,
blkeys
)
}
}
...
...
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