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
6cd6b377
Commit
6cd6b377
authored
Jan 18, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
misc(bitswap): shorten comment and rename var
parent
fe90ed4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
11 deletions
+7
-11
bitswap.go
bitswap.go
+7
-11
No files found.
bitswap.go
View file @
6cd6b377
...
...
@@ -290,23 +290,19 @@ func (bs *bitswap) clientWorker(parent context.Context) {
case
<-
broadcastSignal
:
// resend unfulfilled wantlist keys
bs
.
sendWantlistToProviders
(
ctx
)
broadcastSignal
=
time
.
After
(
rebroadcastDelay
.
Get
())
case
ks
:=
<-
bs
.
batchRequests
:
if
len
(
ks
)
==
0
{
case
k
ey
s
:=
<-
bs
.
batchRequests
:
if
len
(
k
ey
s
)
==
0
{
log
.
Warning
(
"Received batch request for zero blocks"
)
continue
}
for
i
,
k
:=
range
ks
{
for
i
,
k
:=
range
k
ey
s
{
bs
.
wantlist
.
Add
(
k
,
kMaxPriority
-
i
)
}
// NB: send want list to providers for the first peer in this list.
// the assumption is made that the providers of the first key in
// the set are likely to have others as well.
// This currently holds true in most every situation, since when
// pinning a file, you store and provide all blocks associated with
// it. Later, this assumption may not hold as true if we implement
// newer bitswap strategies.
// NB: Optimization. Assumes that providers of key[0] are likely to
// be able to provide for all keys. This currently holds true in most
// every situation. Later, this assumption may not hold as true.
child
,
_
:=
context
.
WithTimeout
(
ctx
,
providerRequestTimeout
)
providers
:=
bs
.
network
.
FindProvidersAsync
(
child
,
ks
[
0
],
maxProvidersPerRequest
)
providers
:=
bs
.
network
.
FindProvidersAsync
(
child
,
k
ey
s
[
0
],
maxProvidersPerRequest
)
err
:=
bs
.
sendWantlistToPeers
(
ctx
,
providers
)
if
err
!=
nil
{
log
.
Errorf
(
"error sending wantlist: %s"
,
err
)
...
...
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