walletdb: minor.

This commit is contained in:
Christopher Jeffrey 2016-07-15 03:03:47 -07:00
parent f4a70df1a0
commit cbd8447d80
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 16 additions and 4 deletions

View File

@ -2671,5 +2671,5 @@ utils.isAlpha = function isAlpha(key) {
if (typeof key !== 'string')
return false;
// We allow /-~ (exclusive), 0-} (inclusive)
return /^[\u0030-\u007d]+$/.test(key);
return key.length !== 0 && /^[\u0030-\u007d]+$/.test(key);
};

View File

@ -659,6 +659,12 @@ WalletDB.prototype.has = function has(id, callback) {
if (!id)
return callback(null, false);
if (this.watchers[id])
return callback(null, true);
if (this.walletCache.has(id))
return callback(null, true);
this.db.has('w/' + id, callback);
};
@ -883,6 +889,7 @@ WalletDB.prototype.createAccount = function createAccount(options, callback) {
WalletDB.prototype.hasAccount = function hasAccount(id, account, callback) {
var self = this;
var key;
if (!id)
return callback(null, false);
@ -894,7 +901,12 @@ WalletDB.prototype.hasAccount = function hasAccount(id, account, callback) {
if (index === -1)
return callback(null, false);
self.db.has('a/' + id + '/' + index, callback);
key = id + '/' + index;
if (self.accountCache.has(key))
return callback(null, true);
self.db.has('a/' + key, callback);
});
};
@ -1359,9 +1371,9 @@ WalletDB.prototype.createAddress = function createAddress(id, name, change, call
});
};
WalletDB.prototype.fill = function fill(id, tx, options, callback) {
WalletDB.prototype.fund = function fund(id, tx, options, callback) {
this.fetchWallet(id, callback, function(wallet, callback) {
wallet.fill(tx, options, callback);
wallet.fund(tx, options, callback);
});
};