|
|
@ -1,6 +1,7 @@ |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var _ = require('lodash'); |
|
|
|
var async = require('async'); |
|
|
|
var $ = require('preconditions').singleton(); |
|
|
|
var log = require('npmlog'); |
|
|
|
log.debug = log.verbose; |
|
|
@ -114,8 +115,10 @@ Insight.prototype.getTransactions = function(addresses, from, to, cb) { |
|
|
|
}; |
|
|
|
|
|
|
|
Insight.prototype.getAddressActivity = function(addresses, cb) { |
|
|
|
function getOneAddressActivity(address, cb) { |
|
|
|
var url = this.url + this.apiPrefix + '/addr/' + address; |
|
|
|
var self = this; |
|
|
|
|
|
|
|
function getOneAddressActivity(address, cb2) { |
|
|
|
var url = self.url + self.apiPrefix + '/addr/' + address; |
|
|
|
var args = { |
|
|
|
method: 'GET', |
|
|
|
url: url, |
|
|
@ -123,21 +126,26 @@ Insight.prototype.getAddressActivity = function(addresses, cb) { |
|
|
|
}; |
|
|
|
|
|
|
|
request(args, function(err, res, result) { |
|
|
|
if (res && res.statusCode == 404) return cb(); |
|
|
|
if (res && res.statusCode == 404) return cb2(); |
|
|
|
if (err || res.statusCode !== 200) |
|
|
|
return cb(_parseErr(err, res)); |
|
|
|
return cb2(_parseErr(err, res)); |
|
|
|
|
|
|
|
var nbTxs = result.unconfirmedTxApperances + result.txApperances; |
|
|
|
return cb(null, nbTxs > 0); |
|
|
|
return cb2(null, nbTxs > 0); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
addresses = [].concat(addresses); |
|
|
|
|
|
|
|
if (addresses.length == 1) { |
|
|
|
return getOneAddressActivity(addresses[0], cb); |
|
|
|
} |
|
|
|
|
|
|
|
var activityFound = false; |
|
|
|
var i = 0; |
|
|
|
|
|
|
|
async.until(function() { |
|
|
|
return activityFound; |
|
|
|
return i == addresses.length || activityFound; |
|
|
|
}, function(next) { |
|
|
|
getOneAddressActivity(addresses[i++], function(err, res) { |
|
|
|
if (err) return next(err); |
|
|
|