Browse Source

Fix #167

At startup, keep trying to verify rpc connection (and pull metadata) until success.
master
Dan Janosik 5 years ago
parent
commit
f23e029548
No known key found for this signature in database GPG Key ID: C6F8CE9FFDB2CED2
  1. 48
      app.js

48
app.js

@ -178,6 +178,34 @@ function loadHistoricalDataForChain(chain) {
} }
} }
function verifyRpcConnection() {
if (!global.activeBlockchain) {
debugLog(`Trying to verify RPC connection...`);
coreApi.getNetworkInfo().then(function(getnetworkinfo) {
coreApi.getBlockchainInfo().then(function(getblockchaininfo) {
global.activeBlockchain = getblockchaininfo.chain;
// localservicenames introduced in 0.19
var services = getnetworkinfo.localservicesnames ? ("[" + getnetworkinfo.localservicesnames.join(", ") + "]") : getnetworkinfo.localservices;
debugLog(`RPC Connected: version=${getnetworkinfo.version} (${getnetworkinfo.subversion}), protocolversion=${getnetworkinfo.protocolversion}, chain=${getblockchaininfo.chain}, services=${services}`);
// load historical/fun items for this chain
loadHistoricalDataForChain(global.activeBlockchain);
// we've verified rpc connection, no need to keep trying
clearInterval(global.verifyRpcConnectionIntervalId);
}).catch(function(err) {
utils.logError("329u0wsdgewg6ed", err);
});
}).catch(function(err) {
utils.logError("32ugegdfsde", err);
});
}
}
app.onStartup = function() { app.onStartup = function() {
global.config = config; global.config = config;
@ -234,24 +262,12 @@ app.continueStartup = function() {
global.rpcClientNoTimeout = new bitcoinCore(rpcClientNoTimeoutProperties); global.rpcClientNoTimeout = new bitcoinCore(rpcClientNoTimeoutProperties);
coreApi.getNetworkInfo().then(function(getnetworkinfo) {
coreApi.getBlockchainInfo().then(function(getblockchaininfo) {
global.activeBlockchain = getblockchaininfo.chain;
// localservicenames introduced in 0.19
var services = getnetworkinfo.localservicesnames ? ("[" + getnetworkinfo.localservicesnames.join(", ") + "]") : getnetworkinfo.localservices;
debugLog(`RPC Connected: version=${getnetworkinfo.version} (${getnetworkinfo.subversion}), protocolversion=${getnetworkinfo.protocolversion}, chain=${getblockchaininfo.chain}, services=${services}`); // keep trying to verify rpc connection until we succeed
// note: see verifyRpcConnection() for associated clearInterval() after success
verifyRpcConnection();
global.verifyRpcConnectionIntervalId = setInterval(verifyRpcConnection, 30000);
// load historical/fun items for this chain
loadHistoricalDataForChain(global.activeBlockchain);
}).catch(function(err) {
utils.logError("329u0wsdgewg6ed", err);
});
}).catch(function(err) {
utils.logError("32ugegdfsde", err);
});
if (config.donations.addresses) { if (config.donations.addresses) {
var getDonationAddressQrCode = function(coinId) { var getDonationAddressQrCode = function(coinId) {

Loading…
Cancel
Save