refactor key handing in storage (part 1)
This commit is contained in:
parent
eb9ab115d7
commit
691951a86a
3 changed files with 16 additions and 15 deletions
|
|
@ -330,12 +330,10 @@ Storage.prototype.getLastOpened = function(cb) {
|
|||
this.getGlobal('lastOpened', cb);
|
||||
};
|
||||
|
||||
Storage.prototype.setFromObj = function(walletId, obj, cb) {
|
||||
Storage.prototype.setFromObj = function(key, obj, cb) {
|
||||
preconditions.checkArgument(key);
|
||||
preconditions.checkArgument(cb);
|
||||
var self = this;
|
||||
|
||||
var key = 'wallet::' + walletId + ((obj.opts && obj.opts.name) ? '_' + obj.opts.name : '');
|
||||
self._write(key, obj, function() {
|
||||
this._write(key, obj, function() {
|
||||
return cb();
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -873,7 +873,10 @@ Wallet.prototype.keepAlive = function() {
|
|||
Wallet.prototype.store = function(cb) {
|
||||
var self = this;
|
||||
this.keepAlive();
|
||||
this.storage.setFromObj(this.id, this.toObj(), function(err) {
|
||||
|
||||
var val = this.toObj();
|
||||
var key = 'wallet::' + this.id + ((val.opts && val.opts.name) ? '_' + obj.opts.name : '');
|
||||
this.storage.setFromObj(key, val, function(err) {
|
||||
log.debug('Wallet stored');
|
||||
if (cb)
|
||||
cb(err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue