From 28216754df63e4e3f5f1e953c760b7beb2a80535 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 23 Sep 2014 11:17:25 -0700 Subject: [PATCH] emit txs. --- example/index.js | 10 +++++++--- lib/bitcoind.js | 11 +++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/example/index.js b/example/index.js index a6f7fce5..f6c6546a 100755 --- a/example/index.js +++ b/example/index.js @@ -15,9 +15,13 @@ bitcoind.start(function(err) { bitcoind.on('open', function(status) { console.log('bitcoind: status="%s"', status); // getBlocks(bitcoind); - bitcoind.on('block', function(block) { - console.log('Found block:'); - console.log(block); + // bitcoind.on('block', function(block) { + // console.log('Found block:'); + // console.log(block); + // }); + bitcoind.on('tx', function(tx) { + console.log('Found tx:'); + console.log(tx); }); }); }); diff --git a/lib/bitcoind.js b/lib/bitcoind.js index 80e02bab..94b800fd 100644 --- a/lib/bitcoind.js +++ b/lib/bitcoind.js @@ -146,8 +146,15 @@ Bitcoin.prototype.start = function(callback) { self.emit('block', block); - return setImmediate(function() { - nextBlock(); + return utils.forEach(block.tx, function(tx, nextTx) { + self.emit('tx', tx); + return setImmediate(function() { + return nextTx(); + }); + }, function() { + return setImmediate(function() { + return nextBlock(); + }); }); }, function() { return setTimeout(next, self.pollInterval);