Browse Source

Optional querying of utxo set:

For use with future features. Disabled by default to protect slow devices.
master
Dan Janosik 5 years ago
parent
commit
c2f6870fc0
No known key found for this signature in database GPG Key ID: C6F8CE9FFDB2CED2
  1. 2
      CHANGELOG.md
  2. 28
      app.js
  3. 7
      app/api/coreApi.js
  4. 7
      app/api/rpcApi.js
  5. 3
      app/config.js
  6. 3
      bin/cli.js

2
CHANGELOG.md

@ -1,6 +1,8 @@
#### v1.2.0
##### 2020-02-23
* Optional querying of UTXO set summary
* Note: this is disabled by default to protect slow nodes. Set 'BTCEXP_SLOW_DEVICE_MODE' to false in your `.env` file to enjoy this feature.
* New tool `/mining-summary` for viewing summarized mining data from recent blocks
#### v1.1.9

28
app.js

@ -218,6 +218,28 @@ function onRpcConnectionVerified(getnetworkinfo, getblockchaininfo) {
}
}
function refreshUtxoSetSummary() {
if (config.slowDeviceMode) {
global.utxoSetSummary = null;
global.utxoSetSummaryPending = false;
debugLog("Skipping performance-intensive task: fetch UTXO set summary. This is skipped due to the flag 'slowDeviceMode' which defaults to 'true' to protect slow nodes. Set this flag to 'false' to enjoy UTXO set summary details.");
return;
}
// flag that we're working on calculating UTXO details (to differentiate cases where we don't have the details and we're not going to try computing them)
global.utxoSetSummaryPending = true;
coreApi.getUtxoSetSummary().then(function(result) {
global.utxoSetSummary = result;
result.lastUpdated = Date.now();
debugLog("Refreshed utxo summary: " + JSON.stringify(result));
});
}
app.onStartup = function() {
global.config = config;
@ -313,6 +335,10 @@ app.continueStartup = function() {
utils.logMemoryUsage();
setInterval(utils.logMemoryUsage, 5000);
refreshUtxoSetSummary();
setInterval(refreshUtxoSetSummary, 30 * 60 * 1000);
};
app.use(function(req, res, next) {
@ -341,6 +367,8 @@ app.use(function(req, res, next) {
res.locals.config = global.config;
res.locals.coinConfig = global.coinConfig;
res.locals.utxoSetSummary = global.utxoSetSummary;
res.locals.utxoSetSummaryPending = global.utxoSetSummaryPending;
res.locals.host = req.session.host;
res.locals.port = req.session.port;

7
app/api/coreApi.js

@ -173,6 +173,10 @@ function getChainTxStats(blockCount) {
});
}
function getUtxoSetSummary() {
return tryCacheThenRpcApi(miscCache, "getUtxoSetSummary", 15 * 60 * 1000, rpcApi.getUtxoSetSummary);
}
function getTxCountStats(dataPtCount, blockStart, blockEnd) {
return new Promise(function(resolve, reject) {
var dataPoints = dataPtCount;
@ -956,5 +960,6 @@ module.exports = {
getPeerSummary: getPeerSummary,
getChainTxStats: getChainTxStats,
getMempoolDetails: getMempoolDetails,
getTxCountStats: getTxCountStats
getTxCountStats: getTxCountStats,
getUtxoSetSummary: getUtxoSetSummary,
};

7
app/api/rpcApi.js

@ -57,6 +57,10 @@ function getMempoolTxids() {
return getRpcDataWithParams({method:"getrawmempool", parameters:[false]});
}
function getUtxoSetSummary() {
return getRpcData("gettxoutsetinfo");
}
function getRawMempool() {
return new Promise(function(resolve, reject) {
getRpcDataWithParams({method:"getrawmempool", parameters:[false]}).then(function(txids) {
@ -343,5 +347,6 @@ module.exports = {
getRpcMethodHelp: getRpcMethodHelp,
getAddress: getAddress,
getPeerInfo: getPeerInfo,
getChainTxStats: getChainTxStats
getChainTxStats: getChainTxStats,
getUtxoSetSummary: getUtxoSetSummary,
};

3
app/config.js

@ -39,7 +39,7 @@ for (var i = 0; i < electrumXServerUriStrings.length; i++) {
}
});
["BTCEXP_NO_RATES", "BTCEXP_UI_SHOW_TOOLS_SUBHEADER"].forEach(function(item) {
["BTCEXP_NO_RATES", "BTCEXP_UI_SHOW_TOOLS_SUBHEADER", "BTCEXP_SLOW_DEVICE_MODE"].forEach(function(item) {
if (process.env[item] === undefined) {
process.env[item] = "true";
}
@ -51,6 +51,7 @@ module.exports = {
cookieSecret: cookieSecret,
privacyMode: (process.env.BTCEXP_PRIVACY_MODE.toLowerCase() == "true"),
slowDeviceMode: (process.env.BTCEXP_SLOW_DEVICE_MODE.toLowerCase() == "true"),
demoSite: (process.env.BTCEXP_DEMO.toLowerCase() == "true"),
queryExchangeRates: (process.env.BTCEXP_NO_RATES.toLowerCase() != "true"),
noInmemoryRpcCache: (process.env.BTCEXP_NO_INMEMORY_RPC_CACHE.toLowerCase() == "true"),

3
bin/cli.js

@ -25,6 +25,7 @@ const args = require('meow')(`
--cookie-secret <secret> secret key for signed cookie hmac generation [default: hmac derive from bitcoind pass]
--demo enable demoSite mode [default: disabled]
--no-rates disable fetching of currency exchange rates [default: enabled]
--slow-device-mode disable performance-intensive tasks (e.g. UTXO set fetching) [default: enabled]
--privacy-mode enable privacyMode to disable external data requests [default: disabled]
--max-mem <bytes> value for max_old_space_size [default: 1024 (1 GB)]
@ -52,7 +53,7 @@ const args = require('meow')(`
, bitcoindCookie: {alias:'c'}, bitcoindUser: {alias:'u'}, bitcoindPass: {alias:'w'}
, demo: {type:'boolean'}, rpcAllowall: {type:'boolean'}, electrumxServers: {alias:'E'}
, nodeEnv: {alias:'e', default:'production'}
, privacyMode: {type:'boolean'}
, privacyMode: {type:'boolean'}, slowDeviceMode: {type:'boolean'}
} }
).flags;

Loading…
Cancel
Save