Commit 580584a9 authored by Jeromy Johnson's avatar Jeromy Johnson Committed by GitHub

Merge pull request #3379 from ipfs/kevina/blockstore-nonewkey

blockstore: fix TODO and avoid calling ds.NewKey
parents 10915f34 d48d9044
...@@ -196,7 +196,7 @@ func (bs *blockstore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error) ...@@ -196,7 +196,7 @@ func (bs *blockstore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
} }
// need to convert to key.Key using key.KeyFromDsKey. // need to convert to key.Key using key.KeyFromDsKey.
c, err := dshelp.DsKeyToCid(ds.NewKey(e.Key)) // TODO: calling NewKey isnt free c, err := dshelp.DsKeyStringToCid(e.Key)
if err != nil { if err != nil {
log.Warningf("error parsing key from DsKey: ", err) log.Warningf("error parsing key from DsKey: ", err)
return nil, true return nil, true
......
...@@ -26,3 +26,11 @@ func DsKeyToCid(dsKey ds.Key) (*cid.Cid, error) { ...@@ -26,3 +26,11 @@ func DsKeyToCid(dsKey ds.Key) (*cid.Cid, error) {
} }
return cid.Cast(kb) return cid.Cast(kb)
} }
func DsKeyStringToCid(dsKey string) (*cid.Cid, error) {
kb, err := base32.RawStdEncoding.DecodeString(dsKey[1:])
if err != nil {
return nil, err
}
return cid.Cast(kb)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment