Refactor IPFS pinner

This commit is contained in:
2019-06-12 01:08:07 +02:00
parent b09c2830c8
commit 6d6c6056f0
6 changed files with 73 additions and 52 deletions

View File

@@ -41,6 +41,14 @@ class IPFS {
return this._ipfsAPI.cat(ipfsHash);
}
pin (hashData) {
let ipfsHash = hashData; // default - if it is a string
if (hashData.hasOwnProperty('hashSize')) {
ipfsHash = this.encodeHash(hashData);
}
return this._ipfsAPI.pin.add(multihashes.toB58String(ipfsHash));
}
decodeHash (ipfsHash) {
let multihash = multihashes.decode(multihashes.fromB58String(ipfsHash));
return {