mv blockExplorer -> blockchainExplorer

This commit is contained in:
Ivan Socolsky 2015-03-30 20:16:51 -03:00
parent f4fb471ace
commit cf73449e7c
3 changed files with 22 additions and 22 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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) {