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
f4c929d4
Commit
f4c929d4
authored
Feb 27, 2019
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove verifcid as it is handled in go-cid
parent
da91d9e4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
36 deletions
+0
-36
blockservice.go
blockservice.go
+0
-30
package.json
package.json
+0
-6
No files found.
blockservice.go
View file @
f4c929d4
...
@@ -14,7 +14,6 @@ import (
...
@@ -14,7 +14,6 @@ import (
blockstore
"github.com/ipfs/go-ipfs-blockstore"
blockstore
"github.com/ipfs/go-ipfs-blockstore"
exchange
"github.com/ipfs/go-ipfs-exchange-interface"
exchange
"github.com/ipfs/go-ipfs-exchange-interface"
logging
"github.com/ipfs/go-log"
logging
"github.com/ipfs/go-log"
"github.com/ipfs/go-verifcid"
)
)
var
log
=
logging
.
Logger
(
"blockservice"
)
var
log
=
logging
.
Logger
(
"blockservice"
)
...
@@ -131,11 +130,6 @@ func NewSession(ctx context.Context, bs BlockService) *Session {
...
@@ -131,11 +130,6 @@ func NewSession(ctx context.Context, bs BlockService) *Session {
// TODO pass a context into this if the remote.HasBlock is going to remain here.
// TODO pass a context into this if the remote.HasBlock is going to remain here.
func
(
s
*
blockService
)
AddBlock
(
o
blocks
.
Block
)
error
{
func
(
s
*
blockService
)
AddBlock
(
o
blocks
.
Block
)
error
{
c
:=
o
.
Cid
()
c
:=
o
.
Cid
()
// hash security
err
:=
verifcid
.
ValidateCid
(
c
)
if
err
!=
nil
{
return
err
}
if
s
.
checkFirst
{
if
s
.
checkFirst
{
if
has
,
err
:=
s
.
blockstore
.
Has
(
c
);
has
||
err
!=
nil
{
if
has
,
err
:=
s
.
blockstore
.
Has
(
c
);
has
||
err
!=
nil
{
return
err
return
err
...
@@ -156,13 +150,6 @@ func (s *blockService) AddBlock(o blocks.Block) error {
...
@@ -156,13 +150,6 @@ func (s *blockService) AddBlock(o blocks.Block) error {
}
}
func
(
s
*
blockService
)
AddBlocks
(
bs
[]
blocks
.
Block
)
error
{
func
(
s
*
blockService
)
AddBlocks
(
bs
[]
blocks
.
Block
)
error
{
// hash security
for
_
,
b
:=
range
bs
{
err
:=
verifcid
.
ValidateCid
(
b
.
Cid
())
if
err
!=
nil
{
return
err
}
}
var
toput
[]
blocks
.
Block
var
toput
[]
blocks
.
Block
if
s
.
checkFirst
{
if
s
.
checkFirst
{
toput
=
make
([]
blocks
.
Block
,
0
,
len
(
bs
))
toput
=
make
([]
blocks
.
Block
,
0
,
len
(
bs
))
...
@@ -211,11 +198,6 @@ func (s *blockService) getExchange() exchange.Fetcher {
...
@@ -211,11 +198,6 @@ func (s *blockService) getExchange() exchange.Fetcher {
}
}
func
getBlock
(
ctx
context
.
Context
,
c
cid
.
Cid
,
bs
blockstore
.
Blockstore
,
fget
func
()
exchange
.
Fetcher
)
(
blocks
.
Block
,
error
)
{
func
getBlock
(
ctx
context
.
Context
,
c
cid
.
Cid
,
bs
blockstore
.
Blockstore
,
fget
func
()
exchange
.
Fetcher
)
(
blocks
.
Block
,
error
)
{
err
:=
verifcid
.
ValidateCid
(
c
)
// hash security
if
err
!=
nil
{
return
nil
,
err
}
block
,
err
:=
bs
.
Get
(
c
)
block
,
err
:=
bs
.
Get
(
c
)
if
err
==
nil
{
if
err
==
nil
{
return
block
,
nil
return
block
,
nil
...
@@ -259,18 +241,6 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
...
@@ -259,18 +241,6 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
go
func
()
{
go
func
()
{
defer
close
(
out
)
defer
close
(
out
)
k
:=
0
for
_
,
c
:=
range
ks
{
// hash security
if
err
:=
verifcid
.
ValidateCid
(
c
);
err
==
nil
{
ks
[
k
]
=
c
k
++
}
else
{
log
.
Errorf
(
"unsafe CID (%s) passed to blockService.GetBlocks: %s"
,
c
,
err
)
}
}
ks
=
ks
[
:
k
]
var
misses
[]
cid
.
Cid
var
misses
[]
cid
.
Cid
for
_
,
c
:=
range
ks
{
for
_
,
c
:=
range
ks
{
hit
,
err
:=
bs
.
Get
(
c
)
hit
,
err
:=
bs
.
Get
(
c
)
...
...
package.json
View file @
f4c929d4
...
@@ -36,12 +36,6 @@
...
@@ -36,12 +36,6 @@
"hash"
:
"QmYYLnAzR28nAQ4U5MFniLprnktu6eTFKibeNt96V21EZK"
,
"hash"
:
"QmYYLnAzR28nAQ4U5MFniLprnktu6eTFKibeNt96V21EZK"
,
"name"
:
"go-block-format"
,
"name"
:
"go-block-format"
,
"version"
:
"0.2.2"
"version"
:
"0.2.2"
},
{
"author"
:
"why"
,
"hash"
:
"QmcVd2ApQdbfaYPKhCjj4WoQuxk4CMxPqmNpijKmFLh6qa"
,
"name"
:
"go-verifcid"
,
"version"
:
"0.1.2"
}
}
],
],
"gxVersion"
:
"0.12.1"
,
"gxVersion"
:
"0.12.1"
,
...
...
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