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

@@ -9,6 +9,18 @@ class Record extends Base {
return Promise.all(records);
});
}
pinIpfsHashes () {
return this.count.then(count => {
let promises = [...Array(count).keys()].map(i => {
let id = i + 1; // 0 => 1 - ids start with 1 and not with 0
return this.getData(id).then(data => {
return this.ipfs.pin(data);
});
});
return Promise.all(promises);
});
}
}
module.exports = Record;