pool: fix relay of pending TX

This commit is contained in:
Fedor Indutny 2014-05-15 15:08:33 +04:00
parent 3c6949e756
commit c69660d81d

View File

@ -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);