bip152: add extra limit to avoid hashdos.
This commit is contained in:
parent
69b862df42
commit
6c901a19fa
@ -417,6 +417,13 @@ CompactBlock.prototype.init = function init() {
|
||||
if (this.totalTX > consensus.MAX_BLOCK_SIZE / 10)
|
||||
throw new Error('Compact block too big.');
|
||||
|
||||
// Custom limit to avoid hashdos:
|
||||
// Min valid tx size: (4 + 1 + 41 + 1 + 9 + 4) = 60
|
||||
// Min block header size: 81
|
||||
// Max number of transactions: (1000000 - 81) / 60 = 16665
|
||||
if (this.totalTX > (consensus.MAX_BLOCK_SIZE - 81) / 60)
|
||||
throw new Error('Compact block too big.');
|
||||
|
||||
// No sparse arrays here, v8.
|
||||
for (let i = 0; i < this.totalTX; i++)
|
||||
this.available.push(null);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user