pool: better stalling for compact blocks.
This commit is contained in:
parent
4aecaf9158
commit
19525826e3
@ -54,6 +54,7 @@ function CompactBlock(options) {
|
|||||||
this.count = 0;
|
this.count = 0;
|
||||||
this.sipKey = null;
|
this.sipKey = null;
|
||||||
this.totalTX = 0;
|
this.totalTX = 0;
|
||||||
|
this.now = 0;
|
||||||
|
|
||||||
if (options)
|
if (options)
|
||||||
this.fromOptions(options);
|
this.fromOptions(options);
|
||||||
|
|||||||
@ -1289,7 +1289,7 @@ Peer.prototype.fulfill = function fulfill(packet) {
|
|||||||
Peer.prototype.maybeTimeout = function maybeTimeout() {
|
Peer.prototype.maybeTimeout = function maybeTimeout() {
|
||||||
var keys = this.responseMap.keys();
|
var keys = this.responseMap.keys();
|
||||||
var now = util.ms();
|
var now = util.ms();
|
||||||
var i, key, entry, name, ts, mult;
|
var i, key, entry, name, ts, block, mult;
|
||||||
|
|
||||||
for (i = 0; i < keys.length; i++) {
|
for (i = 0; i < keys.length; i++) {
|
||||||
key = keys[i];
|
key = keys[i];
|
||||||
@ -1343,6 +1343,18 @@ Peer.prototype.maybeTimeout = function maybeTimeout() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keys = this.compactBlocks.keys();
|
||||||
|
|
||||||
|
for (i = 0; i < keys.length; i++) {
|
||||||
|
key = keys[i];
|
||||||
|
block = this.compactBlocks.get(key);
|
||||||
|
if (now > block.now + Peer.RESPONSE_TIMEOUT) {
|
||||||
|
this.error('Peer is stalling (blocktxn).');
|
||||||
|
this.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now > this.ts + 60000) {
|
if (now > this.ts + 60000) {
|
||||||
|
|||||||
@ -2842,6 +2842,8 @@ Pool.prototype.handleCmpctBlock = co(function* handleCmpctBlock(peer, packet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
block.now = util.ms();
|
||||||
|
|
||||||
assert(!peer.compactBlocks.has(hash));
|
assert(!peer.compactBlocks.has(hash));
|
||||||
peer.compactBlocks.set(hash, block);
|
peer.compactBlocks.set(hash, block);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user