Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!transactionPool) {
return h.continue;
}
// NOTE: this will only trigger if the JSON content-type header is not
// present. This will be avoided by the "content-type.js" plugin in the
// future which is currently disabled due to v1 still being on mainnet.
if (!request.payload.transactions) {
return Boom.badRequest();
}
const transactionsCount = request.payload.transactions.length;
const maxTransactionsPerRequest = transactionPool.maxTransactionsPerRequest;
if (transactionsCount > maxTransactionsPerRequest) {
return Boom.entityTooLarge(
`Received ${transactionsCount} transactions. Only ${maxTransactionsPerRequest} are allowed per request.`,
{
allowed: maxTransactionsPerRequest,
received: transactionsCount,
},
);
}
return h.continue;
},
});
_write(chunk, encoding, next) {
if (this.settings.maxBytes &&
this.length + chunk.length > this.settings.maxBytes) {
return this.emit('error', Boom.entityTooLarge('Payload content length greater than maximum allowed: ' + this.settings.maxBytes));
}
this.length = this.length + chunk.length;
this.buffers.push(chunk);
next();
}
const onReqData = (data) => {
this._bytes += Buffer.byteLength(data);
if (this._bytes > this._maxBytes) {
finish(Boom.entityTooLarge('Maximum size exceeded'));
}
};