pool: add block to chain after _response()
This commit is contained in:
parent
2ee4c7cd3a
commit
7a8d6a1018
@ -272,8 +272,8 @@ Pool.prototype._addPeer = function _addPeer() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
peer.on('merkleblock', function(block) {
|
peer.on('merkleblock', function(block) {
|
||||||
self.chain.add(block);
|
|
||||||
self._response(block);
|
self._response(block);
|
||||||
|
self.chain.add(block);
|
||||||
self.emit('block', block);
|
self.emit('block', block);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -439,6 +439,9 @@ Pool.prototype._request = function _request(type, hash, options, cb) {
|
|||||||
if (has)
|
if (has)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (self.destroyed)
|
||||||
|
return;
|
||||||
|
|
||||||
var req = new LoadRequest(self, type, hex, cb);
|
var req = new LoadRequest(self, type, hex, cb);
|
||||||
req.add(options.noQueue);
|
req.add(options.noQueue);
|
||||||
}
|
}
|
||||||
@ -600,15 +603,15 @@ Pool.prototype.destroy = function destroy() {
|
|||||||
if (this.peers.load)
|
if (this.peers.load)
|
||||||
this.peers.load.destroy();
|
this.peers.load.destroy();
|
||||||
|
|
||||||
|
this.request.queue.slice().forEach(function(item) {
|
||||||
|
item.finish(null);
|
||||||
|
});
|
||||||
this.peers.pending.slice().forEach(function(peer) {
|
this.peers.pending.slice().forEach(function(peer) {
|
||||||
peer.destroy();
|
peer.destroy();
|
||||||
});
|
});
|
||||||
this.peers.block.slice().forEach(function(peer) {
|
this.peers.block.slice().forEach(function(peer) {
|
||||||
peer.destroy();
|
peer.destroy();
|
||||||
});
|
});
|
||||||
this.request.queue.slice().forEach(function(item) {
|
|
||||||
item.finish(null);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Pool.prototype.toJSON = function toJSON() {
|
Pool.prototype.toJSON = function toJSON() {
|
||||||
|
|||||||
@ -51,10 +51,9 @@ TXPool.prototype.add = function add(tx, noWrite) {
|
|||||||
// Do not add TX two times
|
// Do not add TX two times
|
||||||
if (this._all[hash]) {
|
if (this._all[hash]) {
|
||||||
// Transaction was confirmed, update it in storage
|
// 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;
|
this._all[hash].ts = tx.ts;
|
||||||
if (this._storage)
|
this._storeTX(hash, tx);
|
||||||
this._storeTX(hash, tx);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user