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
a2a4327b
Commit
a2a4327b
authored
Nov 21, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use @maybebtc's ForwardBlocks function
parent
f1eb07d9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
24 deletions
+2
-24
bitswap.go
bitswap.go
+2
-24
No files found.
bitswap.go
View file @
a2a4327b
...
...
@@ -16,6 +16,7 @@ import (
strategy
"github.com/jbenet/go-ipfs/exchange/bitswap/strategy"
peer
"github.com/jbenet/go-ipfs/peer"
u
"github.com/jbenet/go-ipfs/util"
async
"github.com/jbenet/go-ipfs/util/async"
"github.com/jbenet/go-ipfs/util/eventlog"
)
...
...
@@ -128,35 +129,12 @@ func (bs *bitswap) GetBlocks(ctx context.Context, keys []u.Key) (<-chan *blocks.
promise
:=
bs
.
notifications
.
Subscribe
(
ctx
,
keys
...
)
select
{
case
bs
.
batchRequests
<-
keys
:
return
pipeBlocks
(
ctx
,
promise
,
len
(
keys
)),
nil
return
async
.
ForwardN
(
ctx
,
promise
,
len
(
keys
)),
nil
case
<-
ctx
.
Done
()
:
return
nil
,
ctx
.
Err
()
}
}
func
pipeBlocks
(
ctx
context
.
Context
,
in
<-
chan
*
blocks
.
Block
,
count
int
)
<-
chan
*
blocks
.
Block
{
out
:=
make
(
chan
*
blocks
.
Block
,
1
)
go
func
()
{
defer
close
(
out
)
for
i
:=
0
;
i
<
count
;
i
++
{
select
{
case
blk
,
ok
:=
<-
in
:
if
!
ok
{
return
}
select
{
case
out
<-
blk
:
case
<-
ctx
.
Done
()
:
return
}
case
<-
ctx
.
Done
()
:
return
}
}
}()
return
out
}
func
(
bs
*
bitswap
)
sendWantListTo
(
ctx
context
.
Context
,
peers
<-
chan
peer
.
Peer
)
error
{
if
peers
==
nil
{
panic
(
"Cant send wantlist to nil peerchan"
)
...
...
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