wallet: handle account init errors.
This commit is contained in:
parent
41a94dacd2
commit
02ccde4f8a
@ -729,15 +729,13 @@ Wallet.prototype._createAccount = co(function* createAccount(options) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
account = Account.fromOptions(this.db, options);
|
account = Account.fromOptions(this.db, options);
|
||||||
|
account.wallet = this;
|
||||||
|
yield account.init();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.drop();
|
this.drop();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
account.wallet = this;
|
|
||||||
|
|
||||||
yield account.init();
|
|
||||||
|
|
||||||
this.logger.info('Created account %s/%s/%d.',
|
this.logger.info('Created account %s/%s/%d.',
|
||||||
account.id,
|
account.id,
|
||||||
account.name,
|
account.name,
|
||||||
@ -761,10 +759,10 @@ Wallet.prototype.ensureAccount = co(function* ensureAccount(options) {
|
|||||||
var name = options.name;
|
var name = options.name;
|
||||||
var account = yield this.getAccount(name);
|
var account = yield this.getAccount(name);
|
||||||
|
|
||||||
if (!account)
|
if (account)
|
||||||
return yield this.createAccount(options);
|
return account;
|
||||||
|
|
||||||
return account;
|
return yield this.createAccount(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user