Browse Source

debug logging; handle a missing rejection

fix-133-memory-crash
Dan Janosik 6 years ago
parent
commit
a8c5c449e5
No known key found for this signature in database GPG Key ID: C6F8CE9FFDB2CED2
  1. 15
      app/api/coreApi.js
  2. 13
      app/api/rpcApi.js

15
app/api/coreApi.js

@ -1,3 +1,5 @@
var debug = require("debug")("coreApi");
var LRU = require("lru-cache");
var fs = require('fs');
@ -26,7 +28,7 @@ function getGenesisCoinbaseTransactionId() {
function tryCacheThenRpcApi(cache, cacheKey, cacheMaxAge, rpcApiFunction, cacheConditionFunction) {
//console.log("tryCache: " + cacheKey + ", " + cacheMaxAge);
//debug("tryCache: " + cacheKey + ", " + cacheMaxAge);
if (cacheConditionFunction == null) {
cacheConditionFunction = function(obj) {
return true;
@ -143,6 +145,9 @@ function getTxCountStats(dataPtCount, blockStart, blockEnd) {
}
resolve({txCountStats:txStats, getblockchaininfo:getblockchaininfo, totalTxCount:results[0].txcount});
}).catch(function(err) {
reject(err);
});
});
});
@ -440,10 +445,10 @@ function getMempoolStats() {
summary["satoshiPerByteBucketTotalFees"].push(summary["satoshiPerByteBuckets"][i]["totalFees"]);
}
/*console.log(JSON.stringify(ageBuckets));
console.log(JSON.stringify(ageBucketLabels));
console.log(JSON.stringify(sizeBuckets));
console.log(JSON.stringify(sizeBucketLabels));*/
/*debug(JSON.stringify(ageBuckets));
debug(JSON.stringify(ageBucketLabels));
debug(JSON.stringify(sizeBuckets));
debug(JSON.stringify(sizeBucketLabels));*/
resolve(summary);
});

13
app/api/rpcApi.js

@ -1,3 +1,4 @@
var debug = require('debug')('rpcApi');
var utils = require("../utils.js");
var config = require("../config.js");
var coins = require("../coins.js");
@ -55,7 +56,7 @@ function getBlockByHeight(blockHeight) {
}
function getBlocksByHeight(blockHeights) {
//console.log("getBlocksByHeight: " + blockHeights);
//debug("getBlocksByHeight: " + blockHeights);
return new Promise(function(resolve, reject) {
var batch = [];
@ -97,7 +98,7 @@ function getBlockByHash(blockHash) {
}
function getBlocksByHash(blockHashes) {
console.log("rpc.getBlocksByHash: " + blockHashes);
debug("rpc.getBlocksByHash: " + blockHashes);
return new Promise(function(resolve, reject) {
var batch = [];
@ -158,7 +159,7 @@ function getAddress(address) {
}
function getRawTransactions(txids) {
//console.log("getRawTransactions: " + txids);
//debug("getRawTransactions: " + txids);
return new Promise(function(resolve, reject) {
if (!txids || txids.length == 0) {
@ -372,21 +373,21 @@ function getRpcDataWithParams(cmd, params) {
function executeBatchesSequentially(batches, resultFunc) {
var batchId = utils.getRandomString(20, 'aA#');
console.log("Starting " + batches.length + "-item batch " + batchId + "...");
debug("Starting " + batches.length + "-item batch " + batchId + "...");
executeBatchesSequentiallyInternal(batchId, batches, 0, [], resultFunc);
}
function executeBatchesSequentiallyInternal(batchId, batches, currentIndex, accumulatedResults, resultFunc) {
if (currentIndex == batches.length) {
console.log("Finishing batch " + batchId + "...");
debug("Finishing batch " + batchId + "...");
resultFunc(accumulatedResults);
return;
}
console.log("Executing item #" + (currentIndex + 1) + " (of " + batches.length + ") for batch " + batchId);
debug("Executing item #" + (currentIndex + 1) + " (of " + batches.length + ") for batch " + batchId);
var count = batches[currentIndex].length;

Loading…
Cancel
Save