Extract healthcheck into its own class
This moves the whole checks if everything is running into its own class and is no longer inside the different functions. Makes the functions smaller and the healthcheck can be used from the client only if wanted/needed.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
const ethers = require('ethers');
|
||||
const RSVP = require('rsvp');
|
||||
|
||||
const Healthcheck = require('./utils/healthcheck');
|
||||
|
||||
const ABIS = {
|
||||
Contributors: require('./abis/Contributors.json'),
|
||||
Operator: require('./abis/Operator.json'),
|
||||
@@ -49,15 +51,9 @@ class Kredits {
|
||||
static setup(provider, signer, ipfsConfig = null) {
|
||||
console.log('Kredits.setup() is deprecated use new Kredits().init() instead');
|
||||
let ipfs = new IPFS(ipfsConfig);
|
||||
|
||||
return ipfs._ipfsAPI.id().catch((error) => {
|
||||
throw new Error(`IPFS node not available; config: ${JSON.stringify(ipfsConfig)} - ${error.message}`);
|
||||
}).then(() => {
|
||||
|
||||
return new Kredits(provider, signer).init().then((kredits) => {
|
||||
kredits.ipfs = ipfs;
|
||||
return kredits;
|
||||
});
|
||||
return new Kredits(provider, signer).init().then((kredits) => {
|
||||
kredits.ipfs = ipfs;
|
||||
return kredits;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,6 +94,10 @@ class Kredits {
|
||||
|
||||
return this.contracts[name];
|
||||
}
|
||||
|
||||
healthcheck() {
|
||||
return new Healthcheck(this).check();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Kredits;
|
||||
|
||||
Reference in New Issue
Block a user