From c69660d81d9b7d971a7b30c5ce4a5d80bfd61590 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 15 May 2014 15:08:33 +0400 Subject: [PATCH] pool: fix relay of pending TX --- lib/bcoin/pool.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bcoin/pool.js b/lib/bcoin/pool.js index 4627a037..bc98aa3d 100644 --- a/lib/bcoin/pool.js +++ b/lib/bcoin/pool.js @@ -378,13 +378,6 @@ Pool.prototype.addWallet = function addWallet(w, defaultTs) { this.watch(w.getHash()); this.watch(w.getPublicKey()); - // Relay pending TXs - // NOTE: It is important to do it after search, because search could - // add TS to pending TXs, thus making them confirmed - w.pending().forEach(function(tx) { - this.sendTX(tx); - }, this); - var self = this; var e = new EventEmitter(); if (w.loaded) @@ -393,6 +386,13 @@ Pool.prototype.addWallet = function addWallet(w, defaultTs) { w.once('load', function(lastTs) { search(w.lastTs) }); function search(ts) { + // Relay pending TXs + // NOTE: It is important to do it after search, because search could + // add TS to pending TXs, thus making them confirmed + w.pending().forEach(function(tx) { + self.sendTX(tx); + }); + // Search for last week by default if (!ts) ts = defaultTs || ((+new Date / 1000) - 7 * 24 * 3600);