Remove IPFS pinner
The pinner now lives in its own npm package
This commit is contained in:
parent
87a468bc91
commit
2316e8f15a
@ -9,18 +9,6 @@ class Record extends Base {
|
|||||||
return Promise.all(records);
|
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;
|
module.exports = Record;
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
class IpfsPinner {
|
|
||||||
constructor (kredits) {
|
|
||||||
this.kredits = kredits;
|
|
||||||
}
|
|
||||||
|
|
||||||
pinAll () {
|
|
||||||
return Promise.all([
|
|
||||||
this.kredits.Contributor.pinIpfsHashes(),
|
|
||||||
this.kredits.Contribution.pinIpfsHashes(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
monitor (callback) {
|
|
||||||
this.kredits.Contribution.on('ContributionAdded', (id) => {
|
|
||||||
this.kredits.Contribution.getData(id)
|
|
||||||
.then(data => { return this.kredits.ipfs.pin(data); })
|
|
||||||
.then(callback);
|
|
||||||
});
|
|
||||||
this.kredits.Contributor.on('ContributorAdded', (id) => {
|
|
||||||
this.kredits.Contribution.getData(id)
|
|
||||||
.then(data => { return this.kredits.ipfs.pin(data); })
|
|
||||||
.then(callback);
|
|
||||||
});
|
|
||||||
this.kredits.Contributor.on('ContributorProfileUpdated', (id) => {
|
|
||||||
this.kredits.Contributor.getData(id)
|
|
||||||
.then(data => { return this.kredits.ipfs.pin(data); })
|
|
||||||
.then(callback);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
module.exports = IpfsPinner;
|
|
@ -1,31 +0,0 @@
|
|||||||
const Kredits = require('../lib/kredits');
|
|
||||||
const IpfsPinner = require('../lib/utils/ipfs-pinner');
|
|
||||||
|
|
||||||
const network = process.env.ETH_NETWORK || 'rinkeby';
|
|
||||||
const rpcUrl = process.env.ETH_RPC_URL;
|
|
||||||
const apm = process.env.APM_DOMAIN || 'open.aragonpm.eth';
|
|
||||||
|
|
||||||
const ipfsConfig = {
|
|
||||||
host: process.env.IPFS_HOST || 'localhost',
|
|
||||||
port: process.env.IPFS_PORT || '5001',
|
|
||||||
protocol: process.env.IPFS_PROTOCOL || 'http',
|
|
||||||
};
|
|
||||||
console.log(`Using IPFS:`, ipfsConfig);
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
const kredits = await Kredits.for({ network, rpcUrl }, { apm, ipfsConfig }).init();
|
|
||||||
const ipfsPinner = new IpfsPinner(kredits);
|
|
||||||
|
|
||||||
ipfsPinner.pinAll().then(pins => {
|
|
||||||
console.log('Pinned', JSON.stringify(pins, null, 2));
|
|
||||||
});
|
|
||||||
ipfsPinner.monitor((pin) => {
|
|
||||||
console.log('Pinned', JSON.stringify(pin));
|
|
||||||
});
|
|
||||||
console.log(`Subscribed to DAO: ${kredits.Kernel.contract.address}`);
|
|
||||||
} catch(e) {
|
|
||||||
console.log(e);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
})();
|
|
Loading…
x
Reference in New Issue
Block a user