peer: better stall detection.
This commit is contained in:
parent
56ccfaa980
commit
a4201e6bd5
@ -1322,6 +1322,18 @@ Peer.prototype.maybeTimeout = function maybeTimeout() {
|
|||||||
this.destroy();
|
this.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keys = this.requestMap.keys();
|
||||||
|
|
||||||
|
for (i = 0; i < keys.length; i++) {
|
||||||
|
key = keys[i];
|
||||||
|
entry = this.requestMap.get(key);
|
||||||
|
if (now > entry + Peer.BLOCK_TIMEOUT) {
|
||||||
|
this.error('Peer is stalling (block).');
|
||||||
|
this.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2455,7 +2455,7 @@ Pool.prototype.handleCmpctBlock = co(function* handleCmpctBlock(peer, packet) {
|
|||||||
peer.destroy();
|
peer.destroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
peer.requestMap.insert(hash);
|
peer.requestMap.set(hash, util.ms());
|
||||||
assert(!this.requestMap.has(hash));
|
assert(!this.requestMap.has(hash));
|
||||||
this.requestMap.insert(hash);
|
this.requestMap.insert(hash);
|
||||||
}
|
}
|
||||||
@ -3012,6 +3012,7 @@ Pool.prototype.getBlocks = co(function* getBlocks(peer, tip, stop) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Pool.prototype.getBlock = function getBlock(peer, hashes) {
|
Pool.prototype.getBlock = function getBlock(peer, hashes) {
|
||||||
|
var now = util.ms();
|
||||||
var items = [];
|
var items = [];
|
||||||
var i, hash;
|
var i, hash;
|
||||||
|
|
||||||
@ -3031,7 +3032,7 @@ Pool.prototype.getBlock = function getBlock(peer, hashes) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
this.requestMap.insert(hash);
|
this.requestMap.insert(hash);
|
||||||
peer.requestMap.insert(hash);
|
peer.requestMap.set(hash, now);
|
||||||
|
|
||||||
items.push(hash);
|
items.push(hash);
|
||||||
}
|
}
|
||||||
@ -3055,6 +3056,7 @@ Pool.prototype.getBlock = function getBlock(peer, hashes) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Pool.prototype.getTX = function getTX(peer, hashes) {
|
Pool.prototype.getTX = function getTX(peer, hashes) {
|
||||||
|
var now = util.ms();
|
||||||
var items = [];
|
var items = [];
|
||||||
var i, hash;
|
var i, hash;
|
||||||
|
|
||||||
@ -3074,7 +3076,7 @@ Pool.prototype.getTX = function getTX(peer, hashes) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
this.requestMap.insert(hash);
|
this.requestMap.insert(hash);
|
||||||
peer.requestMap.insert(hash);
|
peer.requestMap.set(hash, now);
|
||||||
|
|
||||||
items.push(hash);
|
items.push(hash);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user