Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
Merge 039ef23 into 9f27a33
Browse files Browse the repository at this point in the history
  • Loading branch information
matiu committed Apr 12, 2018
2 parents 9f27a33 + 039ef23 commit 6b445af
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
10 changes: 6 additions & 4 deletions lib/blockchainexplorers/insight.js
Expand Up @@ -90,7 +90,7 @@ Insight.prototype._doRequest = function(args, cb) {
var s = JSON.stringify(args);
// if ( s.length > 100 )
// s= s.substr(0,100) + '...';
log.debug('', 'Insight Q: %s', s);
// log.debug('', 'Insight Q: %s', s);

requestList(_.defaults(args, opts), cb);
};
Expand All @@ -102,7 +102,7 @@ Insight.prototype.getConnectionInfo = function() {
/**
* Retrieve a list of unspent outputs associated with an address or set of addresses
*/
Insight.prototype.getUtxos = function(addresses, cb) {
Insight.prototype.getUtxos = function(addresses, cb, walletId) {
var self = this;

var url = this.url + this.apiPrefix + '/addrs/utxo';
Expand All @@ -112,6 +112,7 @@ Insight.prototype.getUtxos = function(addresses, cb) {
json: {
addrs: this.translateQueryAddresses(_.uniq([].concat(addresses))).join(',')
},
walletId: walletId, //only to report
};

this.requestQueue.push(args, function(err, res, unspent) {
Expand Down Expand Up @@ -164,7 +165,7 @@ Insight.prototype.getTransaction = function(txid, cb) {
});
};

Insight.prototype.getTransactions = function(addresses, from, to, cb) {
Insight.prototype.getTransactions = function(addresses, from, to, cb, walletId) {
var self = this;


Expand All @@ -184,7 +185,8 @@ Insight.prototype.getTransactions = function(addresses, from, to, cb) {
json: {
addrs: this.translateQueryAddresses(_.uniq([].concat(addresses))).join(',')
},
timeout: 120000,
timeout: Defaults.INSIGHT_TIMEOUT * 1.2 , // little extra time
walletId: walletId, //only to report
};


Expand Down
10 changes: 7 additions & 3 deletions lib/blockchainexplorers/request-list.js
Expand Up @@ -5,8 +5,12 @@ var $ = require('preconditions').singleton();
var log = require('npmlog');
log.debug = log.verbose;

var Common = require('../common');
var Defaults = Common.Defaults;


var DEFAULT_TIMEOUT= 60000; // 60 s

var DEFAULT_TIMEOUT= Defaults.INSIGHT_TIMEOUT;
/**
* Query a server, using one of the given options
*
Expand Down Expand Up @@ -40,8 +44,8 @@ var requestList = function(args, cb) {

var time = 0;
var interval = setInterval(function() {
time += 10;
log.debug('', 'Delayed insight query: %s, time: %d s', args.uri, time);
time += 20;
log.debug('', 'Delayed insight query: %s, time: %d, wallet: %s s', args.uri, time, args.walletId||'?');
}, 10000);

request(args, function(err, res, body) {
Expand Down
3 changes: 2 additions & 1 deletion lib/common/defaults.js
Expand Up @@ -136,5 +136,6 @@ Defaults.RateLimit = {
};

Defaults.COIN = 'btc';
Defaults.INSIGHT_REQUEST_POOL_SIZE = 20;
Defaults.INSIGHT_REQUEST_POOL_SIZE = 10;
Defaults.INSIGHT_TIMEOUT = 30000;
module.exports = Defaults;
4 changes: 2 additions & 2 deletions lib/server.js
Expand Up @@ -1145,7 +1145,7 @@ WalletService.prototype._getUtxos = function(coin, addresses, cb) {
});

return cb(null, utxos);
});
}, self.walletId);
};

WalletService.prototype._getUtxosForCurrentWallet = function(opts, cb) {
Expand Down Expand Up @@ -3197,7 +3197,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
txs = self._normalizeTxHistory(rawTxs);
totalItems = total;
return next();
});
}, self.walletId);
},
function(next) {
if (!useCache || fromCache) return next();
Expand Down

0 comments on commit 6b445af

Please sign in to comment.