Browse Source

Move explorers inside transport

patch-2
Esteban Ordano 10 years ago
parent
commit
7fe17e1699
  1. 2
      docs/guide/insight.md
  2. 8
      index.js
  3. 3
      lib/transport/explorers/index.js
  4. 11
      lib/transport/explorers/insight.js
  5. 1
      lib/transport/index.js
  6. 6
      test/transport/explorers/insight.js

2
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)

8
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');

3
lib/transport/explorers/index.js

@ -0,0 +1,3 @@
module.exports = {
Insight: require('./insight')
};

11
lib/explorers/insight.js → 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');

1
lib/transport/index.js

@ -2,6 +2,7 @@
* @namespace Transport
*/
module.exports = {
explorers: require('./explorers'),
Messages: require('./messages'),
Peer: require('./peer'),
Pool: require('./pool'),

6
test/explorers/insight.js → 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});
Loading…
Cancel
Save