Browse Source

another startup fix:

since we now make an rpc call to get the active chain before bothering with exchange rates, exchange rates were prone to fail to initialize, either due to slow response to getblockchaininfo call or connecting to a node that's not ready to serve traffic (e.g. verifying blocks). with this change, wait to decide about exchange rate status until we have a verified rpc connection.
master
Dan Janosik 5 years ago
parent
commit
d6a9e4cfeb
No known key found for this signature in database GPG Key ID: C6F8CE9FFDB2CED2
  1. 5
      CHANGELOG.md
  2. 37
      app.js

5
CHANGELOG.md

@ -1,3 +1,8 @@
#### v1.1.5
##### 2019-12-22
* Fix startup issues when connecting to a node that's not ready to serve data (e.g. verifying blocks)
#### v1.1.4
###### 2019-12-04

37
app.js

@ -186,17 +186,11 @@ function verifyRpcConnection() {
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);
onRpcConnectionVerified(getnetworkinfo, getblockchaininfo);
}).catch(function(err) {
utils.logError("329u0wsdgewg6ed", err);
});
@ -206,6 +200,25 @@ function verifyRpcConnection() {
}
}
function onRpcConnectionVerified(getnetworkinfo, getblockchaininfo) {
// 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);
if (global.activeBlockchain == "main") {
if (global.exchangeRates == null) {
utils.refreshExchangeRates();
}
// refresh exchange rate periodically
setInterval(utils.refreshExchangeRates, 1800000);
}
}
app.onStartup = function() {
global.config = config;
@ -313,14 +326,6 @@ app.continueStartup = function() {
setInterval(getSourcecodeProjectMetadata, 3600000);
}
if (global.activeBlockchain == "main") {
if (global.exchangeRates == null) {
utils.refreshExchangeRates();
}
// refresh exchange rate periodically
setInterval(utils.refreshExchangeRates, 1800000);
}
utils.logMemoryUsage();
setInterval(utils.logMemoryUsage, 5000);

Loading…
Cancel
Save