mirror of
https://github.com/janoside/btc-rpc-explorer.git
synced 2026-08-13 12:33:13 +02:00
cleanup
This commit is contained in:
parent
33f33841ca
commit
9f285a69d8
6 changed files with 18 additions and 27 deletions
|
|
@ -1132,7 +1132,7 @@ let mempoolTxSummaryCache = {};
|
|||
function getCachedMempoolTxSummaries() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const allTxids = await utils.timePromise("promises.mempool-summary.getAllMempoolTxids", getAllMempoolTxids());
|
||||
const allTxids = await utils.timePromise("coreApi_mempool_summary_getAllMempoolTxids", getAllMempoolTxids());
|
||||
|
||||
//const txids = allTxids.slice(0, 50); // for debugging
|
||||
const txids = allTxids;
|
||||
|
|
@ -1302,7 +1302,7 @@ function getMempoolTxSummaries(allTxids, statusId, statusFunc) {
|
|||
function buildMempoolSummary(statusId, ageBuckets, sizeBuckets, statusFunc) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const allTxids = await utils.timePromise("promises.mempool-summary.getAllMempoolTxids", getAllMempoolTxids());
|
||||
const allTxids = await utils.timePromise("coreApi_mempool_summary_getAllMempoolTxids", getAllMempoolTxids());
|
||||
|
||||
const txSummaries = await getMempoolTxSummaries(allTxids, statusId, statusFunc);
|
||||
|
||||
|
|
@ -1621,7 +1621,7 @@ function buildMempoolSummary(statusId, ageBuckets, sizeBuckets, statusFunc) {
|
|||
function buildPredictedBlocks(statusId, statusFunc) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const allTxids = await utils.timePromise("promises.mempool-summary.getAllMempoolTxids", getAllMempoolTxids());
|
||||
const allTxids = await utils.timePromise("coreApi_mempool_summary_getAllMempoolTxids", getAllMempoolTxids());
|
||||
|
||||
const txSummaries = await getMempoolTxSummaries(allTxids, statusId, statusFunc);
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ function runOnServer(electrumClient, f) {
|
|||
resolve({result:result, server:electrumClient.host});
|
||||
|
||||
}).catch(function(err) {
|
||||
utils.logError("dif0e21qdh", err, {host:electrumClient.host, port:electrumClient.port});
|
||||
utils.logError("ElectrumServerError", err, {host:electrumClient.host, port:electrumClient.port});
|
||||
|
||||
reject(err);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ function getRpcData(cmd, verifyingConnection=false) {
|
|||
} catch (err) {
|
||||
err.userData = {request:cmd};
|
||||
|
||||
utils.logError("9u4278t5h7rfhgf", err, {request:cmd});
|
||||
utils.logError("RpcError-001", err, {request:cmd});
|
||||
|
||||
logStats(cmd, false, new Date().getTime() - startTime, false);
|
||||
|
||||
|
|
@ -515,7 +515,7 @@ function getRpcDataWithParams(request, verifyingConnection=false) {
|
|||
} catch (err) {
|
||||
err.userData = {request:request};
|
||||
|
||||
utils.logError("283h7ewsede", err, {request:request});
|
||||
utils.logError("RpcError-002", err, {request:`${request.method}${request.parameters ? ("(" + JSON.stringify(request.parameters) + ")") : ""}`});
|
||||
|
||||
logStats(request.method, true, new Date().getTime() - startTime, false);
|
||||
|
||||
|
|
|
|||
19
app/utils.js
19
app/utils.js
|
|
@ -969,22 +969,15 @@ const getCrawlerFromUserAgentString = userAgentString => {
|
|||
};
|
||||
|
||||
const timePromise = async (name, promise) => {
|
||||
try {
|
||||
const startTime = startTimeNanos();
|
||||
const startTime = startTimeNanos();
|
||||
|
||||
const response = await promise;
|
||||
|
||||
const response = await promise;
|
||||
const responseTimeMillis = dtMillis(startTime);
|
||||
|
||||
const responseTimeMillis = dtMillis(startTime);
|
||||
statTracker.trackPerformance(name, responseTimeMillis);
|
||||
|
||||
statTracker.trackPerformance(name, responseTimeMillis);
|
||||
|
||||
return response;
|
||||
|
||||
} catch (e) {
|
||||
logError("238rhgdeaaz-" + name, e);
|
||||
|
||||
throw e;
|
||||
}
|
||||
return response;
|
||||
};
|
||||
|
||||
const timeFunction = (uid, f) => {
|
||||
|
|
|
|||
|
|
@ -242,20 +242,18 @@ router.get("/mining/hashrate", asyncHandler(async (req, res, next) => {
|
|||
|
||||
router.get("/mining/diff-adj-estimate", asyncHandler(async (req, res, next) => {
|
||||
var promises = [];
|
||||
const getblockchaininfo = await utils.timePromise("promises.api.getBlockchainInfo", coreApi.getBlockchainInfo());
|
||||
const getblockchaininfo = await utils.timePromise("api_diffAdjEst_getBlockchainInfo", coreApi.getBlockchainInfo());
|
||||
var currentBlock;
|
||||
var difficultyPeriod = parseInt(Math.floor(getblockchaininfo.blocks / coinConfig.difficultyAdjustmentBlockCount));
|
||||
var difficultyPeriodFirstBlockHeader;
|
||||
|
||||
promises.push(new Promise(async (resolve, reject) => {
|
||||
currentBlock = await utils.timePromise("promises.api.getBlockHeaderByHeight", coreApi.getBlockHeaderByHeight(getblockchaininfo.blocks));
|
||||
resolve();
|
||||
promises.push(utils.safePromise("api_diffAdjEst_getBlockHeaderByHeight", async () => {
|
||||
currentBlock = await coreApi.getBlockHeaderByHeight(getblockchaininfo.blocks);
|
||||
}));
|
||||
|
||||
promises.push(new Promise(async (resolve, reject) => {
|
||||
promises.push(utils.safePromise("api_diffAdjEst_getBlockHeaderByHeight2", async () => {
|
||||
let h = coinConfig.difficultyAdjustmentBlockCount * difficultyPeriod;
|
||||
difficultyPeriodFirstBlockHeader = await utils.timePromise("promises.api.getBlockHeaderByHeight", coreApi.getBlockHeaderByHeight(h));
|
||||
resolve();
|
||||
difficultyPeriodFirstBlockHeader = await coreApi.getBlockHeaderByHeight(h);
|
||||
}));
|
||||
|
||||
await Promise.all(promises);
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ router.get("/", asyncHandler(async (req, res, next) => {
|
|||
|
||||
if (getblockchaininfo.chain !== 'regtest') {
|
||||
/*promises.push(new Promise(async (resolve, reject) => {
|
||||
res.locals.txStats = await utils.timePromise("promises.index.getTxCountStats", coreApi.getTxCountStats(targetBlocksPerDay / 4, -targetBlocksPerDay, "latest"));
|
||||
res.locals.txStats = await utils.timePromise("homepage_getTxCountStats", coreApi.getTxCountStats(targetBlocksPerDay / 4, -targetBlocksPerDay, "latest"));
|
||||
|
||||
resolve();
|
||||
}));*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue