Skip to content

Commit 04e8baf

Browse files
committed
Remove verifcid as it is handled in go-cid
This commit was moved from ipfs/go-blockservice@f4c929d
1 parent e853a5f commit 04e8baf

File tree

1 file changed

+0
-30
lines changed

1 file changed

+0
-30
lines changed

blockservice/blockservice.go

-30
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
blockstore "github.com/ipfs/go-ipfs-blockstore"
1515
exchange "github.com/ipfs/go-ipfs-exchange-interface"
1616
logging "github.com/ipfs/go-log"
17-
"github.com/ipfs/go-verifcid"
1817
)
1918

2019
var log = logging.Logger("blockservice")
@@ -131,11 +130,6 @@ func NewSession(ctx context.Context, bs BlockService) *Session {
131130
// TODO pass a context into this if the remote.HasBlock is going to remain here.
132131
func (s *blockService) AddBlock(o blocks.Block) error {
133132
c := o.Cid()
134-
// hash security
135-
err := verifcid.ValidateCid(c)
136-
if err != nil {
137-
return err
138-
}
139133
if s.checkFirst {
140134
if has, err := s.blockstore.Has(c); has || err != nil {
141135
return err
@@ -156,13 +150,6 @@ func (s *blockService) AddBlock(o blocks.Block) error {
156150
}
157151

158152
func (s *blockService) AddBlocks(bs []blocks.Block) error {
159-
// hash security
160-
for _, b := range bs {
161-
err := verifcid.ValidateCid(b.Cid())
162-
if err != nil {
163-
return err
164-
}
165-
}
166153
var toput []blocks.Block
167154
if s.checkFirst {
168155
toput = make([]blocks.Block, 0, len(bs))
@@ -211,11 +198,6 @@ func (s *blockService) getExchange() exchange.Fetcher {
211198
}
212199

213200
func getBlock(ctx context.Context, c cid.Cid, bs blockstore.Blockstore, fget func() exchange.Fetcher) (blocks.Block, error) {
214-
err := verifcid.ValidateCid(c) // hash security
215-
if err != nil {
216-
return nil, err
217-
}
218-
219201
block, err := bs.Get(c)
220202
if err == nil {
221203
return block, nil
@@ -259,18 +241,6 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
259241
go func() {
260242
defer close(out)
261243

262-
k := 0
263-
for _, c := range ks {
264-
// hash security
265-
if err := verifcid.ValidateCid(c); err == nil {
266-
ks[k] = c
267-
k++
268-
} else {
269-
log.Errorf("unsafe CID (%s) passed to blockService.GetBlocks: %s", c, err)
270-
}
271-
}
272-
ks = ks[:k]
273-
274244
var misses []cid.Cid
275245
for _, c := range ks {
276246
hit, err := bs.Get(c)

0 commit comments

Comments
 (0)