Log a warning when scrypt.maxPending limit is exceeded.
This commit is contained in:
Родитель
a21da17962
Коммит
b64426d1e8
|
@ -34,6 +34,7 @@ module.exports = function(log, config) {
|
|||
function hash(input, salt, N, r, p, len) {
|
||||
var d = P.defer()
|
||||
if (scrypt.maxPending > 0 && scrypt.numPending > scrypt.maxPending) {
|
||||
log.warn({ op: 'scrypt.maxPendingExceeded' })
|
||||
d.reject(new Error('too many pending scrypt hashes'))
|
||||
} else {
|
||||
scrypt.numPending += 1
|
||||
|
|
|
@ -4,8 +4,12 @@
|
|||
|
||||
var test = require('../ptaptest')
|
||||
var promise = require('../../promise')
|
||||
var log = { stat: function(){} }
|
||||
var config = { scrypt: { maxPending: 5 } }
|
||||
var log = {
|
||||
buffer: [],
|
||||
warn: function(obj){ log.buffer.push(obj) },
|
||||
stat: function(){}
|
||||
}
|
||||
|
||||
var scrypt = require('../../crypto/scrypt')(log, config)
|
||||
|
||||
|
@ -44,6 +48,7 @@ test(
|
|||
function (err) {
|
||||
t.equal(err.message, 'too many pending scrypt hashes')
|
||||
t.equal(scrypt.numPendingHWM, 6, 'HWM should be maxPending+1')
|
||||
t.equal(log.buffer[0].op, 'scrypt.maxPendingExceeded')
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче