minor fixes for tx requesting.
This commit is contained in:
parent
e880dc5a5c
commit
c6f91ddd69
@ -815,11 +815,7 @@ Pool.prototype._createPeer = function _createPeer(backoff, priority) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
peer.on('tx', function(tx) {
|
peer.on('tx', function(tx) {
|
||||||
if (self._response(tx))
|
self._response(tx);
|
||||||
utils.debug('Received requested TX: %s', tx.rhash);
|
|
||||||
else
|
|
||||||
utils.debug('Received unrequested TX: %s', tx.rhash);
|
|
||||||
|
|
||||||
self._addTX(tx);
|
self._addTX(tx);
|
||||||
|
|
||||||
self.emit('tx', tx, peer);
|
self.emit('tx', tx, peer);
|
||||||
@ -1400,30 +1396,33 @@ Pool.prototype._doRequests = function _doRequests() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
peerItems = items.filter(function(item) {
|
peerItems = items.filter(function(item) {
|
||||||
return item.initialPeer != null;
|
return item.targetPeer != null;
|
||||||
});
|
});
|
||||||
|
|
||||||
items = items.filter(function(item) {
|
items = items.filter(function(item) {
|
||||||
return item.initialPeer == null;
|
return item.targetPeer == null;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (peerItems.length > 0) {
|
if (peerItems.length > 0) {
|
||||||
peers = utils.uniq(peerItems.map(function(item) {
|
peers = utils.uniq(peerItems.map(function(item) {
|
||||||
assert(item.initialPeer);
|
return item.targetPeer;
|
||||||
return item.initialPeer;
|
|
||||||
}));
|
}));
|
||||||
peers.forEach(function(peer) {
|
peers.forEach(function(peer) {
|
||||||
var items = peerItems.filter(function(item) {
|
var items = peerItems.filter(function(item) {
|
||||||
return item.initialPeer === peer;
|
return item.targetPeer === peer;
|
||||||
});
|
});
|
||||||
|
|
||||||
assert(items.length);
|
assert(items.length);
|
||||||
|
|
||||||
utils.debug(
|
utils.debug(
|
||||||
'Requesting %s/%s items from %s with getdata',
|
'Requesting %d/%d/%d items from %s with getdata',
|
||||||
items.length,
|
items.length,
|
||||||
this.request.queue.length,
|
this.request.queue.length,
|
||||||
|
this.request.active,
|
||||||
peer.host);
|
peer.host);
|
||||||
|
|
||||||
peer.getData(items.map(function(item) {
|
peer.getData(items.map(function(item) {
|
||||||
return item.start(peer);
|
return item.start();
|
||||||
}));
|
}));
|
||||||
}, this);
|
}, this);
|
||||||
}
|
}
|
||||||
@ -1454,9 +1453,10 @@ Pool.prototype._doRequests = function _doRequests() {
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
utils.debug(
|
utils.debug(
|
||||||
'Requesting %s/%s items from %s with getdata',
|
'Requesting %d/%d/%d items from %s with getdata',
|
||||||
req.length,
|
req.length,
|
||||||
this.request.queue.length,
|
this.request.queue.length,
|
||||||
|
this.request.active,
|
||||||
this.peers.load.host);
|
this.peers.load.host);
|
||||||
|
|
||||||
this.peers.load.getData(req);
|
this.peers.load.getData(req);
|
||||||
@ -1855,7 +1855,7 @@ function LoadRequest(pool, type, hash, peer, cb) {
|
|||||||
this.ts = +new Date();
|
this.ts = +new Date();
|
||||||
this.active = false;
|
this.active = false;
|
||||||
this.noQueue = false;
|
this.noQueue = false;
|
||||||
this.initialPeer = peer || null;
|
this.targetPeer = peer || null;
|
||||||
|
|
||||||
this.onclose = function onclose() {
|
this.onclose = function onclose() {
|
||||||
if (self.pool.destroyed)
|
if (self.pool.destroyed)
|
||||||
@ -1881,7 +1881,7 @@ LoadRequest.prototype.start = function start(peer) {
|
|||||||
// self.retry();
|
// self.retry();
|
||||||
// }, this.pool.requestTimeout);
|
// }, this.pool.requestTimeout);
|
||||||
|
|
||||||
this.peer = peer || this.initialPeer;
|
this.peer = peer || this.targetPeer;
|
||||||
this.peer.once('close', this.onclose);
|
this.peer.once('close', this.onclose);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user