From cf73449e7c6743578bf439bac3bd9122cfd2b11f Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Mon, 30 Mar 2015 20:16:51 -0300 Subject: [PATCH] mv blockExplorer -> blockchainExplorer --- ...blockexplorer.js => blockchainexplorer.js} | 4 ++-- lib/server.js | 24 +++++++++---------- test/integration/server.js | 16 ++++++------- 3 files changed, 22 insertions(+), 22 deletions(-) rename lib/{blockexplorer.js => blockchainexplorer.js} (94%) diff --git a/lib/blockexplorer.js b/lib/blockchainexplorer.js similarity index 94% rename from lib/blockexplorer.js rename to lib/blockchainexplorer.js index 5aafea0..70fd076 100644 --- a/lib/blockexplorer.js +++ b/lib/blockchainexplorer.js @@ -10,7 +10,7 @@ var request = require('request'); var io = require('socket.io-client'); -function BlockExplorer(opts) { +function BlockChainExplorer(opts) { $.checkArgument(opts); var provider = opts.provider || 'insight'; var network = opts.network || 'livenet'; @@ -57,4 +57,4 @@ function initSocketInsight(url) { return socket; }; -module.exports = BlockExplorer; +module.exports = BlockChainExplorer; diff --git a/lib/server.js b/lib/server.js index b5bb64e..33ec1e3 100644 --- a/lib/server.js +++ b/lib/server.js @@ -15,7 +15,7 @@ var ClientError = require('./clienterror'); var Utils = require('./utils'); var Storage = require('./storage'); var NotificationBroadcaster = require('./notificationbroadcaster'); -var BlockExplorer = require('./blockexplorer'); +var BlockchainExplorer = require('./blockchainexplorer'); var Wallet = require('./model/wallet'); var Copayer = require('./model/copayer'); @@ -24,7 +24,7 @@ var TxProposal = require('./model/txproposal'); var Notification = require('./model/notification'); var initialized = false; -var storage, blockExplorer; +var storage, blockchainExplorer; /** @@ -36,7 +36,7 @@ function WalletService() { throw new Error('Server not initialized'); this.storage = storage; - this.blockExplorer = blockExplorer; + this.blockchainExplorer = blockchainExplorer; this.notifyTicker = 0; }; @@ -48,12 +48,12 @@ WalletService.onNotification = function(func) { * Initializes global settings for all instances. * @param {Object} opts * @param {Storage} [opts.storage] - The storage provider. - * @param {Storage} [opts.blockExplorer] - The blockExporer provider. + * @param {Storage} [opts.blockchainExplorer] - The blockchainExporer provider. */ WalletService.initialize = function(opts) { opts = opts || {}; storage = opts.storage ||  new Storage(); - blockExplorer = opts.blockExplorer; + blockchainExplorer = opts.blockchainExplorer; initialized = true; }; @@ -335,15 +335,15 @@ WalletService.prototype.verifyMessageSignature = function(opts, cb) { }; -WalletService.prototype._getBlockExplorer = function(provider, network) { - if (!this.blockExplorer) { - this.blockExplorer = new BlockExplorer({ +WalletService.prototype._getBlockchainExplorer = function(provider, network) { + if (!this.blockchainExplorer) { + this.blockchainExplorer = new BlockchainExplorer({ provider: provider, network: network, }); } - return this.blockExplorer; + return this.blockchainExplorer; }; /** @@ -363,7 +363,7 @@ WalletService.prototype._getUtxos = function(cb) { var addressToPath = _.indexBy(addresses, 'address'); // TODO : check performance var networkName = Bitcore.Address(addressStrs[0]).toObject().network; - var bc = self._getBlockExplorer('insight', networkName); + var bc = self._getBlockchainExplorer('insight', networkName); bc.getUnspentUtxos(addressStrs, function(err, inutxos) { if (err) return cb(err); var utxos = _.map(inutxos, function(i) { @@ -669,7 +669,7 @@ WalletService.prototype._broadcastTx = function(txp, cb) { } catch (ex) { return cb(ex); } - var bc = this._getBlockExplorer('insight', txp.getNetworkName()); + var bc = this._getBlockchainExplorer('insight', txp.getNetworkName()); bc.broadcast(raw, function(err, txid) { return cb(err, txid); }) @@ -1014,7 +1014,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) { var addressStrs = _.pluck(addresses, 'address'); var networkName = Bitcore.Address(addressStrs[0]).toObject().network; - var bc = self._getBlockExplorer('insight', networkName); + var bc = self._getBlockchainExplorer('insight', networkName); async.parallel([ function(next) { diff --git a/test/integration/server.js b/test/integration/server.js index b06df71..132ce88 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -150,22 +150,22 @@ helpers.stubUtxos = function(server, wallet, amounts, cb) { }; return obj; }); - blockExplorer.getUnspentUtxos = sinon.stub().callsArgWith(1, null, utxos); + blockchainExplorer.getUnspentUtxos = sinon.stub().callsArgWith(1, null, utxos); return cb(utxos); }); }; helpers.stubBroadcast = function(txid) { - blockExplorer.broadcast = sinon.stub().callsArgWith(1, null, txid); + blockchainExplorer.broadcast = sinon.stub().callsArgWith(1, null, txid); }; helpers.stubBroadcastFail = function() { - blockExplorer.broadcast = sinon.stub().callsArgWith(1, 'broadcast error'); + blockchainExplorer.broadcast = sinon.stub().callsArgWith(1, 'broadcast error'); }; helpers.stubHistory = function(txs) { - blockExplorer.getTransactions = sinon.stub().callsArgWith(1, null, txs); + blockchainExplorer.getTransactions = sinon.stub().callsArgWith(1, null, txs); }; helpers.clientSign = WalletUtils.signTxp; @@ -198,7 +198,7 @@ helpers.createAddresses = function(server, wallet, main, change, cb) { }); }; -var db, storage, blockExplorer; +var db, storage, blockchainExplorer; describe('Copay server', function() { @@ -209,11 +209,11 @@ describe('Copay server', function() { storage = new Storage({ db: db }); - blockExplorer = sinon.stub(); + blockchainExplorer = sinon.stub(); WalletService.initialize({ storage: storage, - blockExplorer: blockExplorer, + blockchainExplorer: blockchainExplorer, }); helpers.offset = 0; }); @@ -699,7 +699,7 @@ describe('Copay server', function() { }); }); it('should get balance when there are no funds', function(done) { - blockExplorer.getUnspentUtxos = sinon.stub().callsArgWith(1, null, []); + blockchainExplorer.getUnspentUtxos = sinon.stub().callsArgWith(1, null, []); server.createAddress({}, function(err, address) { should.not.exist(err); server.getBalance({}, function(err, balance) {