add WALLET_LOCKED error on lock timeout
This commit is contained in:
parent
9b5b6db914
commit
524ed773e2
|
@ -29,6 +29,7 @@ var errors = {
|
||||||
UPGRADE_NEEDED: 'Client app needs to be upgraded',
|
UPGRADE_NEEDED: 'Client app needs to be upgraded',
|
||||||
WALLET_ALREADY_EXISTS: 'Wallet already exists',
|
WALLET_ALREADY_EXISTS: 'Wallet already exists',
|
||||||
WALLET_FULL: 'Wallet full',
|
WALLET_FULL: 'Wallet full',
|
||||||
|
WALLET_LOCKED: 'Wallet is locked',
|
||||||
WALLET_NOT_COMPLETE: 'Wallet is not complete',
|
WALLET_NOT_COMPLETE: 'Wallet is not complete',
|
||||||
WALLET_NOT_FOUND: 'Wallet not found',
|
WALLET_NOT_FOUND: 'Wallet not found',
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,8 @@ log.disableColor();
|
||||||
var LocalLock = require('./locallock');
|
var LocalLock = require('./locallock');
|
||||||
var RemoteLock = require('locker');
|
var RemoteLock = require('locker');
|
||||||
|
|
||||||
|
var Errors = require('./errors/errordefinitions');
|
||||||
|
|
||||||
function Lock(opts) {
|
function Lock(opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
if (opts.lockerServer) {
|
if (opts.lockerServer) {
|
||||||
|
@ -29,7 +31,7 @@ Lock.prototype.runLocked = function(token, cb, task) {
|
||||||
$.shouldBeDefined(token);
|
$.shouldBeDefined(token);
|
||||||
|
|
||||||
this.lock.locked(token, 5 * 1000, 24 * 60 * 60 * 1000, function(err, release) {
|
this.lock.locked(token, 5 * 1000, 24 * 60 * 60 * 1000, function(err, release) {
|
||||||
if (err) return cb(new Error('Wallet is locked'));
|
if (err) return cb(Errors.WALLET_LOCKED);
|
||||||
var _cb = function() {
|
var _cb = function() {
|
||||||
cb.apply(null, arguments);
|
cb.apply(null, arguments);
|
||||||
release();
|
release();
|
||||||
|
|
Loading…
Reference in New Issue