diff --git a/example/as.js b/example/as.js new file mode 100644 index 00000000..69eed45e --- /dev/null +++ b/example/as.js @@ -0,0 +1,58 @@ +var async = require('async'); + +var d = Date.now(); + +var i = 0; + +function fn1(next) { + console.log('fn1'); + setImmediate(function() { + next(null, []) + }); +} + +function fn2(next) { + console.log('fn2'); + setImmediate(function() { + next(null, []) + }); +} + +async.whilst( + function() { + return i < 100000; + }, + function(callback) { + i++; + async.series( + [ + fn1.bind(this), + fn2.bind(this) + ], + callback + ); + }, + function() { + console.log('Milliseconds', Date.now() - d); + } +); + +/*async.times(100000, function(n, next) { + async.series( + [ + function fn1(next) { + setImmediate(function() { + next(null, []); + }); + }, + function fn2(next) { + setImmediate(function() { + next(null, []); + }); + } + ], + next + ); +}, function() { + console.log('Milliseconds', Date.now() - d); +});*/ diff --git a/example/getblock.js b/example/getblock.js index 18ff23fd..4d0147ac 100644 --- a/example/getblock.js +++ b/example/getblock.js @@ -10,7 +10,7 @@ process.title = 'bitcoind.js'; * bitcoind */ -var bitcoind = require('../index.js')({ +var bitcoind = require('../index.js').bitcoind({ directory: '~/.bitcoin' }); diff --git a/example/index.js b/example/index.js index b1db8701..f92ff64f 100755 --- a/example/index.js +++ b/example/index.js @@ -12,7 +12,7 @@ process.title = 'bitcoind.js'; * bitcoind */ -var bitcoind = require('../')({ +var bitcoind = require('../').bitcoind({ directory: process.env.BITCOINDJS_DIR || '~/.bitcoin' }); diff --git a/example/bitcoind.js b/example/node.js similarity index 91% rename from example/bitcoind.js rename to example/node.js index 320ebf2a..bafc2e37 100644 --- a/example/bitcoind.js +++ b/example/node.js @@ -1,9 +1,10 @@ 'use strict'; -var BitcoinNode = require('../lib/node'); +var BitcoindJS = require('..'); +var BitcoinNode = BitcoindJS.Node; var chainlib = require('chainlib'); var log = chainlib.log; -log.debug = function() {}; +//log.debug = function() {}; var privkey = 'tprv8ZgxMBicQKsPdj1QowoT9z1tY5Et38qaMjCHZVoPdPFb6narfmYkqTygEVHfUmY78k3HcaEpkyNCAQDANaXtwNe1HLFvcA7nqYj1B7wTSTo'; diff --git a/index.js b/index.js index a52e200e..61e821df 100644 --- a/index.js +++ b/index.js @@ -1 +1,13 @@ -module.exports = require('./lib/bitcoind.js'); +'use strict'; + +module.exports = {}; +module.exports.bitcoind = require('./lib/bitcoind'); +module.exports.Node = require('./lib/node'); +module.exports.Block = require('./lib/block'); +module.exports.Chain = require('./lib/chain'); +module.exports.DB = require('./lib/db'); +module.exports.Transaction = require('./lib/transaction'); +module.exports.errors = require('./lib/errors'); + +module.exports.deps = {}; +module.exports.deps.chainlib = require('chainlib'); \ No newline at end of file