pool: add block to chain after _response()

This commit is contained in:
Fedor Indutny 2014-05-10 02:05:37 +04:00
parent 2ee4c7cd3a
commit 7a8d6a1018
2 changed files with 9 additions and 7 deletions

View File

@ -272,8 +272,8 @@ Pool.prototype._addPeer = function _addPeer() {
});
peer.on('merkleblock', function(block) {
self.chain.add(block);
self._response(block);
self.chain.add(block);
self.emit('block', block);
});
@ -439,6 +439,9 @@ Pool.prototype._request = function _request(type, hash, options, cb) {
if (has)
return;
if (self.destroyed)
return;
var req = new LoadRequest(self, type, hex, cb);
req.add(options.noQueue);
}
@ -600,15 +603,15 @@ Pool.prototype.destroy = function destroy() {
if (this.peers.load)
this.peers.load.destroy();
this.request.queue.slice().forEach(function(item) {
item.finish(null);
});
this.peers.pending.slice().forEach(function(peer) {
peer.destroy();
});
this.peers.block.slice().forEach(function(peer) {
peer.destroy();
});
this.request.queue.slice().forEach(function(item) {
item.finish(null);
});
};
Pool.prototype.toJSON = function toJSON() {

View File

@ -51,10 +51,9 @@ TXPool.prototype.add = function add(tx, noWrite) {
// Do not add TX two times
if (this._all[hash]) {
// Transaction was confirmed, update it in storage
if (tx.ts !== 0 && this._all[hash].ts === 0) {
if (this._storage && tx.ts !== 0 && this._all[hash].ts === 0) {
this._all[hash].ts = tx.ts;
if (this._storage)
this._storeTX(hash, tx);
this._storeTX(hash, tx);
}
return false;
}