diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index 28745490..1fc8ddd0 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -18,6 +18,7 @@ function Pool(options) { this.redundancy = 2; this.load = { timeout: options.loadTimeout || 5000, + interval: options.loadInterval || 5000, window: options.loadWindow || 250, timer: null, lwm: options.lwm || this.parallel * 2, @@ -101,10 +102,15 @@ Pool.prototype._addLoader = function _addLoader() { peer.once('close', onclose); function onclose() { clearTimeout(timer); + clearInterval(interval); self._removePeer(peer); self._addLoader(); }; + var interval = setInterval(function() { + self._load(); + }, this.load.interval); + peer.once('ack', function() { peer.updateWatch(); if (!self._load()) @@ -115,7 +121,6 @@ Pool.prototype._addLoader = function _addLoader() { // Chain is full and up-to-date if (self.block.lastHash === null && self.chain.isFull()) { clearTimeout(timer); - peer.removeListener('close', onclose); self._removePeer(peer); } diff --git a/lib/bcoin/tx-pool.js b/lib/bcoin/tx-pool.js index 948d21d4..35d2887c 100644 --- a/lib/bcoin/tx-pool.js +++ b/lib/bcoin/tx-pool.js @@ -10,9 +10,12 @@ function TXPool() { } module.exports = TXPool; -TXPool.prototype.add = function add(tx) { +TXPool.prototype.add = function add(tx, wallet) { var hash = tx.hash('hex'); + if (!wallet.own(tx)) + return; + // Do not add TX two times if (this._all[hash]) return false; diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index a9c9b355..172d9b45 100644 --- a/lib/bcoin/wallet.js +++ b/lib/bcoin/wallet.js @@ -149,7 +149,7 @@ Wallet.prototype.sign = function sign(tx, type) { }; Wallet.prototype.addTX = function addTX(tx) { - return this.tx.add(tx); + return this.tx.add(tx, this); }; Wallet.prototype.unspent = function unspent() {