From 7fe17e1699bb849941aac6dc0ec51b531685fa01 Mon Sep 17 00:00:00 2001 From: Esteban Ordano Date: Fri, 2 Jan 2015 16:09:50 -0300 Subject: [PATCH] Move explorers inside transport --- docs/guide/insight.md | 2 +- index.js | 8 ++------ lib/transport/explorers/index.js | 3 +++ lib/{ => transport}/explorers/insight.js | 11 ++++++----- lib/transport/index.js | 1 + test/{ => transport}/explorers/insight.js | 6 +++--- 6 files changed, 16 insertions(+), 15 deletions(-) create mode 100644 lib/transport/explorers/index.js rename lib/{ => transport}/explorers/insight.js (93%) rename test/{ => transport}/explorers/insight.js (96%) diff --git a/docs/guide/insight.md b/docs/guide/insight.md index fdefb03..da12e7e 100644 --- a/docs/guide/insight.md +++ b/docs/guide/insight.md @@ -5,7 +5,7 @@ description: Allows users to fetch information about the state of the blockchain ## Description -`bitcore.explorers.Insight` is a simple agent to perform queries to the blockchain. There are currently two methods (the API will grow as features are requested): `getUnspentUtxos` and `broadcast`. +`bitcore.transport.explorers.Insight` is a simple agent to perform queries to the blockchain. There are currently two methods (the API will grow as features are requested): `getUnspentUtxos` and `broadcast`. ### Retrieving Unspent UTXOs for an Address (or set of) diff --git a/index.js b/index.js index aeb1df0..e72952c 100644 --- a/index.js +++ b/index.js @@ -24,9 +24,6 @@ bitcore.util.buffer = require('./lib/util/buffer'); bitcore.util.js = require('./lib/util/js'); bitcore.util.preconditions = require('./lib/util/preconditions'); -// transport -bitcore.transport = require('./lib/transport'); - // errors thrown by the library bitcore.errors = require('./lib/errors'); @@ -53,9 +50,8 @@ bitcore.deps.bs58 = require('bs58'); bitcore.deps.Buffer = Buffer; bitcore.deps.elliptic = require('elliptic'); -// blockchain explorers -bitcore.explorers = {}; -bitcore.explorers.Insight = require('./lib/explorers/insight'); +// transport +bitcore.transport = require('./lib/transport'); // Internal usage, exposed for testing/advanced tweaking bitcore._HDKeyCache = require('./lib/hdkeycache'); diff --git a/lib/transport/explorers/index.js b/lib/transport/explorers/index.js new file mode 100644 index 0000000..2483955 --- /dev/null +++ b/lib/transport/explorers/index.js @@ -0,0 +1,3 @@ +module.exports = { + Insight: require('./insight') +}; diff --git a/lib/explorers/insight.js b/lib/transport/explorers/insight.js similarity index 93% rename from lib/explorers/insight.js rename to lib/transport/explorers/insight.js index 1a21d11..71a41c5 100644 --- a/lib/explorers/insight.js +++ b/lib/transport/explorers/insight.js @@ -1,11 +1,12 @@ 'use strict'; -var Networks = require('../networks'); -var JSUtil = require('../util/js'); -var $ = require('../util/preconditions'); +var $ = require('../../util/preconditions'); var _ = require('lodash'); -var Address = require('../address'); -var Transaction = require('../transaction'); + +var Address = require('../../address'); +var JSUtil = require('../../util/js'); +var Networks = require('../../networks'); +var Transaction = require('../../transaction'); var UnspentOutput = Transaction.UnspentOutput; var request = require('request'); diff --git a/lib/transport/index.js b/lib/transport/index.js index f219f81..185732e 100644 --- a/lib/transport/index.js +++ b/lib/transport/index.js @@ -2,6 +2,7 @@ * @namespace Transport */ module.exports = { + explorers: require('./explorers'), Messages: require('./messages'), Peer: require('./peer'), Pool: require('./pool'), diff --git a/test/explorers/insight.js b/test/transport/explorers/insight.js similarity index 96% rename from test/explorers/insight.js rename to test/transport/explorers/insight.js index 41b6745..5c04780 100644 --- a/test/explorers/insight.js +++ b/test/transport/explorers/insight.js @@ -3,9 +3,9 @@ var sinon = require('sinon'); var should = require('chai').should(); var expect = require('chai').expect; -var bitcore = require('../..'); +var bitcore = require('../../..'); -var Insight = bitcore.explorers.Insight; +var Insight = bitcore.transport.explorers.Insight; var Address = bitcore.Address; var Transaction = bitcore.Transaction; var Networks = bitcore.Networks; @@ -74,7 +74,7 @@ describe('Insight', function() { describe('broadcasting a transaction', function() { var insight = new Insight(); - var tx = require('../data/tx_creation.json')[0][7]; + var tx = require('../../data/tx_creation.json')[0][7]; beforeEach(function() { insight.requestPost = sinon.stub(); insight.requestPost.onFirstCall().callsArgWith(2, null, {statusCode: 200});