@@ -21,6 +21,10 @@ function invalidPinTypeErr (type) {
2121 return errCode ( new Error ( errMsg ) , 'ERR_INVALID_PIN_TYPE' )
2222}
2323
24+ function toKey ( cid ) {
25+ return '/' + bs58 . encode ( cid . multihash )
26+ }
27+
2428const PinTypes = {
2529 direct : 'direct' ,
2630 recursive : 'recursive' ,
@@ -56,7 +60,7 @@ class PinManager {
5660 async pinDirectly ( cid , options = { } ) {
5761 await this . dag . get ( cid , options )
5862
59- return this . repo . pins . put ( bs58 . encode ( cid . multihash ) , cbor . encode ( {
63+ return this . repo . pins . put ( toKey ( cid ) , cbor . encode ( {
6064 cid : cid . buffer ,
6165 type : PinTypes . direct ,
6266 name : options . name
@@ -83,13 +87,13 @@ class PinManager {
8387 cid = new CID ( cbor . decode ( result . value ) . cid )
8488 }
8589
86- return this . repo . pins . delete ( bs58 . encode ( cid . multihash ) )
90+ return this . repo . pins . delete ( toKey ( cid ) )
8791 }
8892
8993 async pinRecursively ( cid , options = { } ) {
9094 await this . fetchCompleteDag ( cid , options )
9195
92- await this . repo . pins . put ( bs58 . encode ( cid . multihash ) , cbor . encode ( {
96+ await this . repo . pins . put ( toKey ( cid ) , cbor . encode ( {
9397 cid : cid . buffer ,
9498 type : PinTypes . recursive ,
9599 name : options . name
@@ -161,7 +165,7 @@ class PinManager {
161165
162166 if ( recursive || direct || all ) {
163167 const result = await first ( this . repo . pins . query ( {
164- prefix : bs58 . encode ( cid . multihash ) ,
168+ prefix : toKey ( cid ) ,
165169 filters : [ entry => {
166170 const pin = cbor . decode ( entry . value )
167171
0 commit comments