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-blockservice
Commits
ec4d6447
Commit
ec4d6447
authored
Nov 26, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style(blockservice) s/Remote/Exchange
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
a7bfc2f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
blockservice.go
blockservice.go
+7
-7
No files found.
blockservice.go
View file @
ec4d6447
...
...
@@ -25,7 +25,7 @@ var ErrNotFound = errors.New("blockservice: key not found")
type
BlockService
struct
{
// TODO don't expose underlying impl details
Blockstore
blockstore
.
Blockstore
Remote
exchange
.
Interface
Exchange
exchange
.
Interface
}
// NewBlockService creates a BlockService with given datastore instance.
...
...
@@ -36,7 +36,7 @@ func New(bs blockstore.Blockstore, rem exchange.Interface) (*BlockService, error
if
rem
==
nil
{
log
.
Warning
(
"blockservice running in local (offline) mode."
)
}
return
&
BlockService
{
Blockstore
:
bs
,
Remot
e
:
rem
},
nil
return
&
BlockService
{
Blockstore
:
bs
,
Exchang
e
:
rem
},
nil
}
// AddBlock adds a particular block to the service, Putting it into the datastore.
...
...
@@ -66,9 +66,9 @@ func (s *BlockService) AddBlock(b *blocks.Block) (u.Key, error) {
// TODO this operation rate-limits blockservice operations, we should
// consider moving this to an sync process.
if
s
.
Remot
e
!=
nil
{
if
s
.
Exchang
e
!=
nil
{
ctx
:=
context
.
TODO
()
err
=
s
.
Remot
e
.
HasBlock
(
ctx
,
b
)
err
=
s
.
Exchang
e
.
HasBlock
(
ctx
,
b
)
}
return
k
,
err
}
...
...
@@ -82,9 +82,9 @@ func (s *BlockService) GetBlock(ctx context.Context, k u.Key) (*blocks.Block, er
return
block
,
nil
// TODO be careful checking ErrNotFound. If the underlying
// implementation changes, this will break.
}
else
if
err
==
ds
.
ErrNotFound
&&
s
.
Remot
e
!=
nil
{
}
else
if
err
==
ds
.
ErrNotFound
&&
s
.
Exchang
e
!=
nil
{
log
.
Debug
(
"Blockservice: Searching bitswap."
)
blk
,
err
:=
s
.
Remot
e
.
GetBlock
(
ctx
,
k
)
blk
,
err
:=
s
.
Exchang
e
.
GetBlock
(
ctx
,
k
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -117,7 +117,7 @@ func (s *BlockService) GetBlocks(ctx context.Context, ks []u.Key) <-chan *blocks
}
}
rblocks
,
err
:=
s
.
Remot
e
.
GetBlocks
(
ctx
,
misses
)
rblocks
,
err
:=
s
.
Exchang
e
.
GetBlocks
(
ctx
,
misses
)
if
err
!=
nil
{
log
.
Errorf
(
"Error with GetBlocks: %s"
,
err
)
return
...
...
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