mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-05 00:08:06 +08:00
blockstore: fix TODO and avoid calling ds.NewKey
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
This commit is contained in:
parent
8d6ac7a83f
commit
d48d90447b
@ -196,7 +196,7 @@ func (bs *blockstore) AllKeysChan(ctx context.Context) (<-chan *cid.Cid, error)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
log.Warningf("error parsing key from DsKey: ", err)
|
||||
return nil, true
|
||||
|
||||
8
thirdparty/ds-help/key.go
vendored
8
thirdparty/ds-help/key.go
vendored
@ -26,3 +26,11 @@ func DsKeyToCid(dsKey ds.Key) (*cid.Cid, error) {
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user