Fixed parsing error of incoming addresses.
This commit is contained in:
parent
750cda44ae
commit
8873f19a43
@ -23,7 +23,7 @@ var WalletService = function(options) {
|
|||||||
//each job in the cache is already running immediately after setting
|
//each job in the cache is already running immediately after setting
|
||||||
//the job. This means that a large job can be started before smaller
|
//the job. This means that a large job can be started before smaller
|
||||||
//jobs and this can lead to slower processing of all jobs over time.
|
//jobs and this can lead to slower processing of all jobs over time.
|
||||||
this._MAX_QUEUE = 1;
|
this._MAX_QUEUE = 20;
|
||||||
this._jobs = LRU({
|
this._jobs = LRU({
|
||||||
max: this._MAX_QUEUE,
|
max: this._MAX_QUEUE,
|
||||||
maxAge: 86400000 * 3 //3 days
|
maxAge: 86400000 * 3 //3 days
|
||||||
@ -570,7 +570,7 @@ WalletService.prototype._endpointPostAddresses = function() {
|
|||||||
// TODO make imdempotent
|
// TODO make imdempotent
|
||||||
//this could be a long-running operation, so we'll return a job id
|
//this could be a long-running operation, so we'll return a job id
|
||||||
if (!self._isJobQueueReady()) {
|
if (!self._isJobQueueReady()) {
|
||||||
return callback(new Error('Job queue is currently overloaded, please try again later.'), jobResults);
|
return utils.sendError(new Error('Job queue is currently overloaded, please try again later.'), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
var jobId = utils.generateJobId();
|
var jobId = utils.generateJobId();
|
||||||
@ -841,7 +841,7 @@ WalletService.prototype._isJobQueueReady = function() {
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
self._jobs.rforEach(function(value, key) {
|
self._jobs.rforEach(function(value, key) {
|
||||||
if ((value.state === 'complete' || value.state === 'error') && value.reported) {
|
if ((value.status === 'complete' || value.status === 'error') && value.reported) {
|
||||||
self._jobs.del(key);
|
self._jobs.del(key);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -857,7 +857,7 @@ WalletService.prototype._jobCompletionCallback = function(err, results) {
|
|||||||
var job = this._jobs.get(jobId);
|
var job = this._jobs.get(jobId);
|
||||||
|
|
||||||
if (!job) {
|
if (!job) {
|
||||||
log.debug('ERROR: Could not locate job id: ' + jobId +
|
log.error('ERROR: Could not locate job id: ' + jobId +
|
||||||
' in the list of jobs. It may have been purged already although it should not have.');
|
' in the list of jobs. It may have been purged already although it should not have.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,35 +96,6 @@ exports.checkAddress = function(req, res, next) {
|
|||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
//exports.checkAddresses = function(req, res, next) {
|
|
||||||
// var addresses = [];
|
|
||||||
//
|
|
||||||
// if (!req.body.addresses || !req.body.addresses.length || !Array.isArray(req.body.addresses)) {
|
|
||||||
// return utils.sendError({
|
|
||||||
// message: 'Addresses param is expected',
|
|
||||||
// statusCode: 400
|
|
||||||
// }, res);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// assert(req.network, '"network" is expected to be set on the request');
|
|
||||||
//
|
|
||||||
// for (var i = 0; i < req.body.addresses.length; i++) {
|
|
||||||
// var address;
|
|
||||||
// try {
|
|
||||||
// address = new bitcore.Address(req.body.addresses[i], req.network);
|
|
||||||
// } catch(e) {
|
|
||||||
// return utils.sendError({
|
|
||||||
// message: 'Invalid address: ' + e.message,
|
|
||||||
// statusCode: 400
|
|
||||||
// }, res);
|
|
||||||
// }
|
|
||||||
// addresses.push(address);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// req.addresses = addresses;
|
|
||||||
// next();
|
|
||||||
//};
|
|
||||||
|
|
||||||
exports.checkWalletId = function(req, res, next) {
|
exports.checkWalletId = function(req, res, next) {
|
||||||
|
|
||||||
if (!req.params.walletId) {
|
if (!req.params.walletId) {
|
||||||
@ -160,6 +131,9 @@ exports.checkAddresses = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
var buf = req.file.buffer;
|
var buf = req.file.buffer;
|
||||||
var bufString = buf.toString();
|
var bufString = buf.toString();
|
||||||
|
if (bufString.slice(-1) === ',') {
|
||||||
|
var bufString = '[' + bufString.slice(0,-1) + ']';
|
||||||
|
}
|
||||||
req.addresses = parse(bufString);
|
req.addresses = parse(bufString);
|
||||||
if (!req.addresses) {
|
if (!req.addresses) {
|
||||||
generateError(415, 'Could not parse addresses buffer into something meaningful.');
|
generateError(415, 'Could not parse addresses buffer into something meaningful.');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user