|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
#! /usr/bin/env node
|
|
|
|
|
|
|
|
|
|
const debug = require('debug')('ipfs-pinner'); |
|
|
|
|
const Kredits = require('kredits-contracts'); |
|
|
|
|
const IpfsPinner = require('./lib/ipfs-pinner'); |
|
|
|
|
|
|
|
|
@ -32,18 +31,24 @@ console.log(`Using IPFS:`, ipfsConfig);
|
|
|
|
|
{ network: argv.network, rpcUrl: argv.rpcUrl }, |
|
|
|
|
{ apm: argv.apm, ipfsConfig: ipfsConfig, addresses: { Kernel: argv.daoAddress } } |
|
|
|
|
).init(); |
|
|
|
|
await kredits.ipfs._ipfsAPI.id(); // check the connection to the IPFS client TODO: redesign IPFS wrapper API and not use an internal attribute
|
|
|
|
|
|
|
|
|
|
// check the connection to the IPFS client
|
|
|
|
|
// TODO redesign IPFS wrapper API and do not use an internal attribute
|
|
|
|
|
await kredits.ipfs._ipfsAPI.id(); |
|
|
|
|
|
|
|
|
|
const ipfsPinner = new IpfsPinner(kredits); |
|
|
|
|
|
|
|
|
|
ipfsPinner.pinAll().then(pins => { |
|
|
|
|
console.log('Pinned', JSON.stringify(pins, null, 2)); |
|
|
|
|
console.log(`Pinned ${pins.length} existing documents`); |
|
|
|
|
}); |
|
|
|
|
ipfsPinner.monitor((pin) => { |
|
|
|
|
console.log('Pinned', JSON.stringify(pin)); |
|
|
|
|
|
|
|
|
|
ipfsPinner.monitor(pin => { |
|
|
|
|
console.log('Pinned a new document:', pin[0]["hash"]); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
console.log(`Subscribed to DAO: ${kredits.Kernel.contract.address}`); |
|
|
|
|
} catch(e) { |
|
|
|
|
console.log('Failed to start pinner'); |
|
|
|
|
console.log('Failed to start'); |
|
|
|
|
console.log(e); |
|
|
|
|
process.exit(1); |
|
|
|
|
} |
|
|
|
|