set misbehavior for inv and headers.
This commit is contained in:
parent
9ccac80ad6
commit
08f5865e78
@ -1515,6 +1515,11 @@ Peer.prototype._handleInv = function _handleInv(items) {
|
||||
var txs = [];
|
||||
var i, item, unknown;
|
||||
|
||||
if (items.length > 50000) {
|
||||
this.setMisbehavior(100);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < items.length; i++) {
|
||||
item = items[i];
|
||||
if (item.type === constants.inv.TX) {
|
||||
@ -1541,6 +1546,11 @@ Peer.prototype._handleInv = function _handleInv(items) {
|
||||
};
|
||||
|
||||
Peer.prototype._handleHeaders = function _handleHeaders(headers) {
|
||||
if (headers.length > 2000) {
|
||||
this.setMisbehavior(100);
|
||||
return;
|
||||
}
|
||||
|
||||
headers = headers.map(function(header) {
|
||||
return new bcoin.headers(header);
|
||||
});
|
||||
|
||||
@ -574,11 +574,6 @@ Pool.prototype._handleHeaders = function _handleHeaders(headers, peer, callback)
|
||||
headers.length,
|
||||
peer.hostname);
|
||||
|
||||
if (headers.length > 2000) {
|
||||
peer.setMisbehavior(100);
|
||||
return callback();
|
||||
}
|
||||
|
||||
this.emit('headers', headers);
|
||||
|
||||
if (peer === this.peers.load) {
|
||||
@ -639,13 +634,6 @@ Pool.prototype._handleBlocks = function _handleBlocks(hashes, peer, callback) {
|
||||
hashes.length,
|
||||
peer.hostname);
|
||||
|
||||
// Normally this is 500, but with older
|
||||
// versions locator.GetDistanceBack() is called.
|
||||
if (hashes.length > 500) {
|
||||
peer.setMisbehavior(100);
|
||||
return;
|
||||
}
|
||||
|
||||
this.emit('blocks', hashes);
|
||||
|
||||
if (peer === this.peers.load) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user