@cryptotaxi247 / kubo / commits / d48d90447

blockstore: fix TODO and avoid calling ds.NewKey

License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed Nov 14, 2016 at 01:49 UTC d48d90447be429b2c1cb866e29e1ad2ea5a00af3
2 files changed +9 -1
blocks/blockstore/blockstore.go
+1 -1
@@ -196,7 +196,7 @@ func (bs *blockstore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
196 }
197
198 // need to convert to key.Key using key.KeyFromDsKey.
199 - c, err := dshelp.DsKeyToCid(ds.NewKey(e.Key)) // TODO: calling NewKey isnt free
199 + c, err := dshelp.DsKeyStringToCid(e.Key)
200 if err != nil {
201 log.Warningf("error parsing key from DsKey: ", err)
202 return nil, true
thirdparty/ds-help/key.go
+8
@@ -26,3 +26,11 @@ func DsKeyToCid(dsKey ds.Key) (*cid.Cid, error) {
26 }
27 return cid.Cast(kb)
28 }
29 +
30 +func DsKeyStringToCid(dsKey string) (*cid.Cid, error) {
31 + kb, err := base32.RawStdEncoding.DecodeString(dsKey[1:])
32 + if err != nil {
33 + return nil, err
34 + }
35 + return cid.Cast(kb)
36 +}