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
a978cec6
Unverified
Commit
a978cec6
authored
Jun 24, 2020
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid modifying passed in slice of cids
Signed-off-by:
Jakub Sztandera
<
kubuxu@protocol.ai
>
parent
f12f8ae1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
blockservice.go
blockservice.go
+19
-8
No files found.
blockservice.go
View file @
a978cec6
...
@@ -273,17 +273,28 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
...
@@ -273,17 +273,28 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
go
func
()
{
go
func
()
{
defer
close
(
out
)
defer
close
(
out
)
k
:=
0
allValid
:=
true
for
_
,
c
:=
range
ks
{
for
_
,
c
:=
range
ks
{
// hash security
if
err
:=
verifcid
.
ValidateCid
(
c
);
err
!=
nil
{
if
err
:=
verifcid
.
ValidateCid
(
c
);
err
==
nil
{
allValid
=
false
ks
[
k
]
=
c
break
k
++
}
else
{
log
.
Errorf
(
"unsafe CID (%s) passed to blockService.GetBlocks: %s"
,
c
,
err
)
}
}
}
}
ks
=
ks
[
:
k
]
if
!
allValid
{
ks2
:=
make
([]
cid
.
Cid
,
len
(
ks
))
k
:=
0
for
_
,
c
:=
range
ks
{
// hash security
if
err
:=
verifcid
.
ValidateCid
(
c
);
err
==
nil
{
ks2
[
k
]
=
c
k
++
}
else
{
log
.
Errorf
(
"unsafe CID (%s) passed to blockService.GetBlocks: %s"
,
c
,
err
)
}
}
ks
=
ks2
[
:
k
]
}
var
misses
[]
cid
.
Cid
var
misses
[]
cid
.
Cid
for
_
,
c
:=
range
ks
{
for
_
,
c
:=
range
ks
{
...
...
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