Improve initialization
This commit is contained in:
parent
c21512fa0b
commit
9dffb15f45
19
index.js
19
index.js
@ -39,17 +39,23 @@ const ipfsConfig = {
|
|||||||
debug(`IPFS node:`, ipfsConfig);
|
debug(`IPFS node:`, ipfsConfig);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
|
||||||
const kredits = await Kredits.for(
|
const kredits = await Kredits.for(
|
||||||
{ rpcUrl: argv.rpcUrl },
|
{ rpcUrl: argv.rpcUrl },
|
||||||
{ ipfsConfig: ipfsConfig }
|
{ ipfsConfig: ipfsConfig }
|
||||||
).init();
|
).init().catch(e => {
|
||||||
|
console.log('Failed to initialize Kredits:');
|
||||||
|
console.log(e.message);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
// Check the connection to the IPFS client
|
|
||||||
// TODO redesign IPFS wrapper API and do not use an internal attribute
|
// TODO redesign IPFS wrapper API and do not use an internal attribute
|
||||||
const ipfsApi = kredits.ipfs._ipfsAPI;
|
const ipfsApi = kredits.ipfs._ipfsAPI;
|
||||||
|
|
||||||
await ipfsApi.id();
|
await ipfsApi.id().catch(e => {
|
||||||
|
console.log('Failed to initialize IPFS:');
|
||||||
|
console.log(e.message);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
debug(`Connecting to known IPFS node ${argv.bootstrapNode}`);
|
debug(`Connecting to known IPFS node ${argv.bootstrapNode}`);
|
||||||
await ipfsApi.swarm.connect(argv.bootstrapNode);
|
await ipfsApi.swarm.connect(argv.bootstrapNode);
|
||||||
@ -74,9 +80,4 @@ debug(`IPFS node:`, ipfsConfig);
|
|||||||
|
|
||||||
// TODO Add new deployment/DAO/org ID or all contract proxy addresses
|
// TODO Add new deployment/DAO/org ID or all contract proxy addresses
|
||||||
// console.log(`Subscribed to DAO: ${kredits.Kernel.contract.address}`);
|
// console.log(`Subscribed to DAO: ${kredits.Kernel.contract.address}`);
|
||||||
} catch(e) {
|
|
||||||
console.log('Failed to start');
|
|
||||||
console.log(e);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user