mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 10:49:24 +08:00
feat(util) add u.Key().ToDatastore() method
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
|
||||||
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
|
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
|
||||||
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
|
mh "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
|
||||||
)
|
)
|
||||||
@ -31,6 +32,10 @@ var ErrNotFound = errors.New("Error: Not Found.")
|
|||||||
// Key is a string representation of multihash for use with maps.
|
// Key is a string representation of multihash for use with maps.
|
||||||
type Key string
|
type Key string
|
||||||
|
|
||||||
|
func (k Key) DatastoreKey() ds.Key {
|
||||||
|
return ds.NewKey(string(k))
|
||||||
|
}
|
||||||
|
|
||||||
func (k Key) Pretty() string {
|
func (k Key) Pretty() string {
|
||||||
return b58.Encode([]byte(k))
|
return b58.Encode([]byte(k))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user