peer: timeout inv spamming.

This commit is contained in:
Christopher Jeffrey 2017-02-24 02:21:20 -08:00
parent 829e62b079
commit 4c4cf9e6a4
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -199,6 +199,14 @@ Peer.RESPONSE_TIMEOUT = 30000;
Peer.BLOCK_TIMEOUT = 60000;
/**
* Max number of requested items.
* @const {Number}
* @default
*/
Peer.MAX_REQUESTS = 5000;
/**
* Create inbound peer from socket.
* @param {PeerOptions} options
@ -1307,6 +1315,14 @@ Peer.prototype.maybeTimeout = function maybeTimeout() {
return;
}
}
if (this.options.isFull()) {
if (this.requestMap.size > Peer.MAX_REQUESTS) {
this.error('Peer is stalling (data).');
this.destroy();
return;
}
}
};
/**