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-dms3-exchange-offline
Commits
fe186f37
Commit
fe186f37
authored
Jun 01, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move util.Key into its own package under blocks
parent
b1ec37fc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
offline.go
offline.go
+4
-4
offline_test.go
offline_test.go
+4
-4
No files found.
offline.go
View file @
fe186f37
...
...
@@ -6,8 +6,8 @@ import (
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
blocks
"github.com/ipfs/go-ipfs/blocks"
"github.com/ipfs/go-ipfs/blocks/blockstore"
key
"github.com/ipfs/go-ipfs/blocks/key"
exchange
"github.com/ipfs/go-ipfs/exchange"
u
"github.com/ipfs/go-ipfs/util"
)
func
Exchange
(
bs
blockstore
.
Blockstore
)
exchange
.
Interface
{
...
...
@@ -23,7 +23,7 @@ type offlineExchange struct {
// GetBlock returns nil to signal that a block could not be retrieved for the
// given key.
// NB: This function may return before the timeout expires.
func
(
e
*
offlineExchange
)
GetBlock
(
_
context
.
Context
,
k
u
.
Key
)
(
*
blocks
.
Block
,
error
)
{
func
(
e
*
offlineExchange
)
GetBlock
(
_
context
.
Context
,
k
key
.
Key
)
(
*
blocks
.
Block
,
error
)
{
return
e
.
bs
.
Get
(
k
)
}
...
...
@@ -39,11 +39,11 @@ func (_ *offlineExchange) Close() error {
return
nil
}
func
(
e
*
offlineExchange
)
GetBlocks
(
ctx
context
.
Context
,
ks
[]
u
.
Key
)
(
<-
chan
*
blocks
.
Block
,
error
)
{
func
(
e
*
offlineExchange
)
GetBlocks
(
ctx
context
.
Context
,
ks
[]
key
.
Key
)
(
<-
chan
*
blocks
.
Block
,
error
)
{
out
:=
make
(
chan
*
blocks
.
Block
,
0
)
go
func
()
{
defer
close
(
out
)
var
misses
[]
u
.
Key
var
misses
[]
key
.
Key
for
_
,
k
:=
range
ks
{
hit
,
err
:=
e
.
bs
.
Get
(
k
)
if
err
!=
nil
{
...
...
offline_test.go
View file @
fe186f37
...
...
@@ -9,12 +9,12 @@ import (
blocks
"github.com/ipfs/go-ipfs/blocks"
"github.com/ipfs/go-ipfs/blocks/blockstore"
"github.com/ipfs/go-ipfs/blocks/blocksutil"
u
"github.com/ipfs/go-ipfs/
util
"
key
"github.com/ipfs/go-ipfs/
blocks/key
"
)
func
TestBlockReturnsErr
(
t
*
testing
.
T
)
{
off
:=
Exchange
(
bstore
())
_
,
err
:=
off
.
GetBlock
(
context
.
Background
(),
u
.
Key
(
"foo"
))
_
,
err
:=
off
.
GetBlock
(
context
.
Background
(),
key
.
Key
(
"foo"
))
if
err
!=
nil
{
return
// as desired
}
...
...
@@ -49,8 +49,8 @@ func TestGetBlocks(t *testing.T) {
}
}
request
:=
func
()
[]
u
.
Key
{
var
ks
[]
u
.
Key
request
:=
func
()
[]
key
.
Key
{
var
ks
[]
key
.
Key
for
_
,
b
:=
range
expected
{
ks
=
append
(
ks
,
b
.
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