mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 05:52:20 +08:00
blockstore Allkeys: ignore non multihash keys
This commit is contained in:
@ -133,6 +133,13 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (<
|
|||||||
// need to convert to u.Key using u.KeyFromDsKey.
|
// need to convert to u.Key using u.KeyFromDsKey.
|
||||||
k = u.KeyFromDsKey(ds.NewKey(e.Key))
|
k = u.KeyFromDsKey(ds.NewKey(e.Key))
|
||||||
log.Debug("blockstore: query got key", k)
|
log.Debug("blockstore: query got key", k)
|
||||||
|
|
||||||
|
// key must be a multihash. else ignore it.
|
||||||
|
_, err := mh.Cast([]byte(k))
|
||||||
|
if err != nil {
|
||||||
|
return "", true
|
||||||
|
}
|
||||||
|
|
||||||
return k, true
|
return k, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,6 +156,9 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (<
|
|||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if k == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
Reference in New Issue
Block a user