rm removeRepeated fn
This commit is contained in:
parent
260adc8587
commit
91a05a896e
2 changed files with 7 additions and 34 deletions
|
|
@ -38,33 +38,6 @@ function _asyncForEach(array, fn, callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function removeRepeatedElements(ar) {
|
|
||||||
var ya = false,
|
|
||||||
v = "",
|
|
||||||
aux = [].concat(ar),
|
|
||||||
r = Array();
|
|
||||||
for (var i in aux) { //
|
|
||||||
v = aux[i];
|
|
||||||
ya = false;
|
|
||||||
for (var a in aux) {
|
|
||||||
if (v == aux[a]) {
|
|
||||||
if (ya == false) {
|
|
||||||
ya = true;
|
|
||||||
} else {
|
|
||||||
aux[a] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var a in aux) {
|
|
||||||
if (aux[a] != "") {
|
|
||||||
r.push(aux[a]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Insight.prototype._getOptions = function(method, path, data) {
|
Insight.prototype._getOptions = function(method, path, data) {
|
||||||
return {
|
return {
|
||||||
host: this.host,
|
host: this.host,
|
||||||
|
|
@ -121,8 +94,11 @@ Insight.prototype.getTransactions = function(addresses, cb) {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
}, function() {
|
}, function() {
|
||||||
var clean_txids = removeRepeatedElements(txids);
|
var uniqueTxids = {};
|
||||||
_asyncForEach(clean_txids, function(txid, callback2) {
|
for (var k in txids) {
|
||||||
|
uniqueTxids[k] = 1;
|
||||||
|
}
|
||||||
|
_asyncForEach(Object.keys(uniqueTxids), function(txid, callback2) {
|
||||||
var options = self._getOptions('GET', '/api/tx/' + txid);
|
var options = self._getOptions('GET', '/api/tx/' + txid);
|
||||||
self._request(options, function(err, res) {
|
self._request(options, function(err, res) {
|
||||||
txs.push(res);
|
txs.push(res);
|
||||||
|
|
@ -184,8 +160,8 @@ Insight.prototype.checkActivity = function(addresses, cb) {
|
||||||
var getOutputs = function(t) {
|
var getOutputs = function(t) {
|
||||||
return flatArray(
|
return flatArray(
|
||||||
t.vout.map(function(vout) {
|
t.vout.map(function(vout) {
|
||||||
return vout.scriptPubKey.addresses;
|
return vout.scriptPubKey.addresses;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,4 @@ describe('Insight model', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue