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
2ec77aa6
Commit
2ec77aa6
authored
Jul 15, 2019
by
whyrusleeping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nil exchange is okay
parent
ef3f60ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
blockservice.go
blockservice.go
+17
-8
No files found.
blockservice.go
View file @
2ec77aa6
...
@@ -148,8 +148,10 @@ func (s *blockService) AddBlock(o blocks.Block) error {
...
@@ -148,8 +148,10 @@ func (s *blockService) AddBlock(o blocks.Block) error {
log
.
Event
(
context
.
TODO
(),
"BlockService.BlockAdded"
,
c
)
log
.
Event
(
context
.
TODO
(),
"BlockService.BlockAdded"
,
c
)
if
err
:=
s
.
exchange
.
HasBlock
(
o
);
err
!=
nil
{
if
s
.
exchange
!=
nil
{
log
.
Errorf
(
"HasBlock: %s"
,
err
.
Error
())
if
err
:=
s
.
exchange
.
HasBlock
(
o
);
err
!=
nil
{
log
.
Errorf
(
"HasBlock: %s"
,
err
.
Error
())
}
}
}
return
nil
return
nil
...
@@ -184,10 +186,12 @@ func (s *blockService) AddBlocks(bs []blocks.Block) error {
...
@@ -184,10 +186,12 @@ func (s *blockService) AddBlocks(bs []blocks.Block) error {
return
err
return
err
}
}
for
_
,
o
:=
range
toput
{
if
s
.
exchange
!=
nil
{
log
.
Event
(
context
.
TODO
(),
"BlockService.BlockAdded"
,
o
.
Cid
())
for
_
,
o
:=
range
toput
{
if
err
:=
s
.
exchange
.
HasBlock
(
o
);
err
!=
nil
{
log
.
Event
(
context
.
TODO
(),
"BlockService.BlockAdded"
,
o
.
Cid
())
log
.
Errorf
(
"HasBlock: %s"
,
err
.
Error
())
if
err
:=
s
.
exchange
.
HasBlock
(
o
);
err
!=
nil
{
log
.
Errorf
(
"HasBlock: %s"
,
err
.
Error
())
}
}
}
}
}
return
nil
return
nil
...
@@ -250,7 +254,12 @@ func getBlock(ctx context.Context, c cid.Cid, bs blockstore.Blockstore, fget fun
...
@@ -250,7 +254,12 @@ func getBlock(ctx context.Context, c cid.Cid, bs blockstore.Blockstore, fget fun
// the returned channel.
// the returned channel.
// NB: No guarantees are made about order.
// NB: No guarantees are made about order.
func
(
s
*
blockService
)
GetBlocks
(
ctx
context
.
Context
,
ks
[]
cid
.
Cid
)
<-
chan
blocks
.
Block
{
func
(
s
*
blockService
)
GetBlocks
(
ctx
context
.
Context
,
ks
[]
cid
.
Cid
)
<-
chan
blocks
.
Block
{
return
getBlocks
(
ctx
,
ks
,
s
.
blockstore
,
s
.
getExchange
)
// hash security
var
f
func
()
exchange
.
Fetcher
if
s
.
exchange
!=
nil
{
f
=
s
.
getExchange
}
return
getBlocks
(
ctx
,
ks
,
s
.
blockstore
,
f
)
// hash security
}
}
func
getBlocks
(
ctx
context
.
Context
,
ks
[]
cid
.
Cid
,
bs
blockstore
.
Blockstore
,
fget
func
()
exchange
.
Fetcher
)
<-
chan
blocks
.
Block
{
func
getBlocks
(
ctx
context
.
Context
,
ks
[]
cid
.
Cid
,
bs
blockstore
.
Blockstore
,
fget
func
()
exchange
.
Fetcher
)
<-
chan
blocks
.
Block
{
...
@@ -285,7 +294,7 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
...
@@ -285,7 +294,7 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
}
}
}
}
if
len
(
misses
)
==
0
{
if
len
(
misses
)
==
0
||
fget
==
nil
{
return
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