diff --git a/lib/bcoin/peer.js b/lib/bcoin/peer.js index f2cf26cd..dac0813e 100644 --- a/lib/bcoin/peer.js +++ b/lib/bcoin/peer.js @@ -166,6 +166,8 @@ Peer.prototype.destroy = function destroy() { // Private APIs Peer.prototype._write = function write(chunk) { + if (!this.socket) + return; if (NodeBuffer) this.socket.write(new NodeBuffer(chunk)); else diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index 587c4aa4..28745490 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -17,15 +17,15 @@ function Pool(options) { this.parallel = options.parallel || 2000; this.redundancy = 2; this.load = { - timeout: options.loadTimeout || 10000, + timeout: options.loadTimeout || 5000, window: options.loadWindow || 250, timer: null, lwm: options.lwm || this.parallel * 2, hwm: options.hwm || this.parallel * 8, hiReached: false }; - this.maxRetries = options.maxRetries || 300; - this.requestTimeout = options.requestTimeout || 10000; + this.maxRetries = options.maxRetries || 10; + this.requestTimeout = options.requestTimeout || 5000; this.chain = new bcoin.chain(); this.watchMap = {}; this.bloom = new bcoin.bloom(8 * 1024, diff --git a/lib/bcoin/tx-pool.js b/lib/bcoin/tx-pool.js index 94c11a28..948d21d4 100644 --- a/lib/bcoin/tx-pool.js +++ b/lib/bcoin/tx-pool.js @@ -15,7 +15,7 @@ TXPool.prototype.add = function add(tx) { // Do not add TX two times if (this._all[hash]) - return; + return false; this._all[hash] = tx; // Consume unspent money or add orphans @@ -54,6 +54,8 @@ TXPool.prototype.add = function add(tx) { // Add input to orphan orphan.tx.input(tx, orphan.index); } + + return true; }; TXPool.prototype.unspent = function unspent(wallet) { diff --git a/lib/bcoin/wallet.js b/lib/bcoin/wallet.js index 47a2d131..a9c9b355 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) { - this.tx.add(tx); + return this.tx.add(tx); }; Wallet.prototype.unspent = function unspent() {