From 6a8414bcfb16411aae5dad46d467f0b66cdcaf5d Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Sun, 11 Jan 2015 21:19:42 -0800 Subject: [PATCH] blockstore Allkeys: ignore non multihash keys --- blocks/blockstore/blockstore.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/blocks/blockstore/blockstore.go b/blocks/blockstore/blockstore.go index ed24326c9..e4a9f7745 100644 --- a/blocks/blockstore/blockstore.go +++ b/blocks/blockstore/blockstore.go @@ -133,6 +133,13 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (< // need to convert to u.Key using u.KeyFromDsKey. k = u.KeyFromDsKey(ds.NewKey(e.Key)) 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 } } @@ -149,6 +156,9 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (< if !ok { return } + if k == "" { + continue + } select { case <-ctx.Done():