mirror of https://github.com/BTCPrivate/copay.git
emitting event
This commit is contained in:
parent
af721f697e
commit
887e5ecd85
|
@ -237,6 +237,8 @@ Identity.prototype.retrieveWalletFromStorage = function(walletId, opts, cb) {
|
||||||
* @param {Function} cb
|
* @param {Function} cb
|
||||||
*/
|
*/
|
||||||
Identity.prototype.storeWallet = function(wallet, cb) {
|
Identity.prototype.storeWallet = function(wallet, cb) {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
preconditions.checkArgument(wallet && _.isObject(wallet));
|
preconditions.checkArgument(wallet && _.isObject(wallet));
|
||||||
|
|
||||||
wallet.setVersion(this.version);
|
wallet.setVersion(this.version);
|
||||||
|
@ -246,13 +248,13 @@ Identity.prototype.storeWallet = function(wallet, cb) {
|
||||||
|
|
||||||
this.storage.setItem(key, val, function(err) {
|
this.storage.setItem(key, val, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error('Wallet:' + wallet.getName() + ' couldnt be stored:', err);
|
log.error('Wallet:' + wallet.getName() + ' could not be stored:', err);
|
||||||
log.error('Wallet:' + wallet.getName() + ' Size:', JSON.stringify(wallet.sizes()));
|
log.error('Wallet:' + wallet.getName() + ' Size:', JSON.stringify(wallet.sizes()));
|
||||||
|
|
||||||
if (err.match('OVERQUOTA')) {
|
if (err.match('OVERQUOTA')) {
|
||||||
self.emitAndKeepAlive('walletStorageError', w.getId(), 'Storage limits on remote server exceeded');
|
self.emitAndKeepAlive('walletStorageError', wallet.getId(), 'Storage limits on remote server exceeded');
|
||||||
} else {
|
} else {
|
||||||
self.emitAndKeepAlive('walletStorageError', w.getId(), err);
|
self.emitAndKeepAlive('walletStorageError', wallet.getId(), err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cb)
|
if (cb)
|
||||||
|
@ -582,12 +584,9 @@ Identity.prototype.createWallet = function(opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var w = new walletClass(opts);
|
var w = new walletClass(opts);
|
||||||
|
|
||||||
console.log(_.keys(self.wallets));
|
if (self.wallets[w.getId()]) {
|
||||||
console.log(w.getId());
|
|
||||||
if (_.contains(_.keys(self.wallets), w.getId())) {
|
|
||||||
return cb('walletAlreadyExists');
|
return cb('walletAlreadyExists');
|
||||||
}
|
}
|
||||||
|
|
||||||
self.wallets[w.getId()] = w;
|
self.wallets[w.getId()] = w;
|
||||||
self.updateFocusedTimestamp(w.getId());
|
self.updateFocusedTimestamp(w.getId());
|
||||||
self.bindWallet(w);
|
self.bindWallet(w);
|
||||||
|
|
Loading…
Reference in New Issue