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
b62e6559
Commit
b62e6559
authored
Sep 18, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(exchange) pass ctx to exchange.HasBlock(...)
parent
55b425a8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
5 deletions
+4
-5
bitswap.go
bitswap.go
+1
-2
offline.go
offline.go
+1
-1
offline_test.go
offline_test.go
+2
-2
No files found.
bitswap.go
View file @
b62e6559
...
...
@@ -128,8 +128,7 @@ func (bs *bitswap) sendToPeersThatWant(ctx context.Context, block blocks.Block)
// HasBlock announces the existance of a block to bitswap, potentially sending
// it to peers (Partners) whose WantLists include it.
func
(
bs
*
bitswap
)
HasBlock
(
blk
blocks
.
Block
)
error
{
ctx
:=
context
.
TODO
()
func
(
bs
*
bitswap
)
HasBlock
(
ctx
context
.
Context
,
blk
blocks
.
Block
)
error
{
go
bs
.
sendToPeersThatWant
(
ctx
,
blk
)
return
bs
.
routing
.
Provide
(
blk
.
Key
())
}
...
...
offline.go
View file @
b62e6559
...
...
@@ -27,6 +27,6 @@ func (_ *offlineExchange) Block(context.Context, u.Key) (*blocks.Block, error) {
}
// HasBlock always returns nil.
func
(
_
*
offlineExchange
)
HasBlock
(
blocks
.
Block
)
error
{
func
(
_
*
offlineExchange
)
HasBlock
(
context
.
Context
,
blocks
.
Block
)
error
{
return
nil
}
offline_test.go
View file @
b62e6559
...
...
@@ -11,7 +11,7 @@ import (
func
TestBlockReturnsErr
(
t
*
testing
.
T
)
{
off
:=
NewOfflineExchange
()
_
,
err
:=
off
.
Block
(
context
.
TODO
(),
u
.
Key
(
"foo"
))
_
,
err
:=
off
.
Block
(
context
.
Background
(),
u
.
Key
(
"foo"
))
if
err
!=
nil
{
return
// as desired
}
...
...
@@ -21,7 +21,7 @@ func TestBlockReturnsErr(t *testing.T) {
func
TestHasBlockReturnsNil
(
t
*
testing
.
T
)
{
off
:=
NewOfflineExchange
()
block
:=
testutil
.
NewBlockOrFail
(
t
,
"data"
)
err
:=
off
.
HasBlock
(
block
)
err
:=
off
.
HasBlock
(
context
.
Background
(),
block
)
if
err
!=
nil
{
t
.
Fatal
(
""
)
}
...
...
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