From 91a05a896edbfa12b5b4a5ee162430e1fa3de9d9 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 5 Aug 2014 17:18:02 -0300 Subject: [PATCH] rm removeRepeated fn --- js/models/blockchain/Insight.js | 38 ++++++--------------------------- test/test.blockchain.Insight.js | 3 --- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/js/models/blockchain/Insight.js b/js/models/blockchain/Insight.js index 04f007c74..22e1bce7d 100644 --- a/js/models/blockchain/Insight.js +++ b/js/models/blockchain/Insight.js @@ -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) { return { host: this.host, @@ -121,8 +94,11 @@ Insight.prototype.getTransactions = function(addresses, cb) { callback(); }); }, function() { - var clean_txids = removeRepeatedElements(txids); - _asyncForEach(clean_txids, function(txid, callback2) { + var uniqueTxids = {}; + for (var k in txids) { + uniqueTxids[k] = 1; + } + _asyncForEach(Object.keys(uniqueTxids), function(txid, callback2) { var options = self._getOptions('GET', '/api/tx/' + txid); self._request(options, function(err, res) { txs.push(res); @@ -184,8 +160,8 @@ Insight.prototype.checkActivity = function(addresses, cb) { var getOutputs = function(t) { return flatArray( t.vout.map(function(vout) { - return vout.scriptPubKey.addresses; - }) + return vout.scriptPubKey.addresses; + }) ); }; diff --git a/test/test.blockchain.Insight.js b/test/test.blockchain.Insight.js index b5451c99a..e80d628f8 100644 --- a/test/test.blockchain.Insight.js +++ b/test/test.blockchain.Insight.js @@ -229,7 +229,4 @@ describe('Insight model', function() { }); }); - - - });