blockstore Allkeys: ignore non multihash keys
Juan Batiz-Benet committed
Jan 11, 2015 at 21:19 UTC
6a8414bcfb16411aae5dad46d467f0b66cdcaf5d
1 file changed
+10
blocks/blockstore/blockstore.go
+10
@@ -133,6 +133,13 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (<
133
// need to convert to u.Key using u.KeyFromDsKey.
134
k = u.KeyFromDsKey(ds.NewKey(e.Key))
135
log.Debug("blockstore: query got key", k)
136
+
137
+ // key must be a multihash. else ignore it.
138
+ _, err := mh.Cast([]byte(k))
139
+ if err != nil {
140
+ return "", true
141
+ }
142
+
143
return k, true
144
}
145
}
@@ -149,6 +156,9 @@ func (bs *blockstore) AllKeysChan(ctx context.Context, offset int, limit int) (<
156
if !ok {
157
return
158
}
159
+ if k == "" {
160
+ continue
161
+ }
162
163
select {
164
case <-ctx.Done():