From 3cac0a96d213cce33bc7cc0e0ae1e8bc3dbf561b Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 22 Aug 2016 19:08:39 -0700 Subject: [PATCH] http: better events. --- lib/bcoin/http/server.js | 9 +-------- test/chain-test.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/bcoin/http/server.js b/lib/bcoin/http/server.js index 19c95100..7ac56d46 100644 --- a/lib/bcoin/http/server.js +++ b/lib/bcoin/http/server.js @@ -1214,15 +1214,8 @@ function ClientSocket(server, socket) { this.filter = {}; this.filterCount = 0; - this.node = this.server.node; - this.network = this.server.network; this.chain = this.server.chain; this.mempool = this.server.mempool; - this.pool = this.server.pool; - this.fees = this.server.fees; - this.miner = this.server.miner; - this.wallet = this.server.wallet; - this.walletdb = this.server.walletdb; this.logger = this.server.logger; this.events = []; @@ -1248,7 +1241,7 @@ ClientSocket.prototype._init = function _init() { else ack = self.socket.ack(packet.id); - emit.apply(self, [event, args, ack]); + emit.call(self, event, args, ack); return result; }; diff --git a/test/chain-test.js b/test/chain-test.js index 15225593..f57212db 100644 --- a/test/chain-test.js +++ b/test/chain-test.js @@ -195,9 +195,10 @@ describe('Chain', function() { assert.ifError(err); chain.add(block, function(err) { assert.ifError(err); - chain.db.getCoin(block.txs[1].hash('hex'), 1, function(err, coin) { + var tx = block.txs[1]; + var output = bcoin.coin.fromTX(tx, 1); + chain.db.getCoin(tx.hash('hex'), 1, function(err, coin) { assert.ifError(err); - var output = bcoin.coin.fromTX(block.txs[1], 1); assert.deepEqual(coin.toRaw(), output.toRaw()); cb(); }); @@ -228,15 +229,15 @@ describe('Chain', function() { }); it('should rescan for transactions', function(cb) { - var txs = []; + var total = 0; walletdb.getAddressHashes(function(err, hashes) { assert.ifError(err); - chain.db.scan(null, hashes, function(block, tx, next) { - txs = txs.concat(tx); + chain.db.scan(null, hashes, function(block, txs, next) { + total += txs.length; next(); }, function(err) { assert.ifError(err); - assert.equal(txs.length, 25); + assert.equal(total, 25); cb(); }); }); @@ -244,6 +245,6 @@ describe('Chain', function() { it('should cleanup', function(cb) { constants.tx.COINBASE_MATURITY = 100; - cb(); + node.close(cb); }); });