diff --git a/bench/walletdb.js b/bench/walletdb.js index a22b4616..54824f0b 100644 --- a/bench/walletdb.js +++ b/bench/walletdb.js @@ -48,7 +48,7 @@ function runBench(callback) { }, function(next) { var end = bench('accounts'); - utils.forRange(0, 5000, function(i, next) { + utils.forRange(0, 1000, function(i, next) { wallet.createAccount({}, function(err, account) { assert.ifError(err); addrs.push(account.receiveAddress.getAddress()); diff --git a/lib/bcoin/walletdb.js b/lib/bcoin/walletdb.js index fd5e366a..025a7552 100644 --- a/lib/bcoin/walletdb.js +++ b/lib/bcoin/walletdb.js @@ -54,8 +54,9 @@ function WalletDB(options) { // We need one read lock for `get` and `create`. // It will hold locks specific to wallet ids. this.readLock = new ReadLock(this); - this.accountCache = new bcoin.lru(100000, 1); - this.walletCache = new bcoin.lru(100000, 1); + + this.accountCache = new bcoin.lru(10000, 1); + this.walletCache = new bcoin.lru(10000, 1); this.pathCache = new bcoin.lru(100000, 1); this.db = bcoin.ldb({ @@ -450,6 +451,13 @@ WalletDB.prototype.get = function get(id, callback) { }); }; +/** + * Get a wallet from the database, do not setup watcher. + * @private + * @param {WalletID} id + * @param {Function} callback - Returns [Error, {@link Wallet}]. + */ + WalletDB.prototype._get = function get(id, callback) { var self = this; var wallet; @@ -655,6 +663,14 @@ WalletDB.prototype.getAccount = function getAccount(id, name, callback) { }); }; +/** + * Get an account from the database. Do not setup watcher. + * @private + * @param {WalletID} id + * @param {Number} index - Account index. + * @param {Function} callback - Returns [Error, {@link Wallet}]. + */ + WalletDB.prototype._getAccount = function getAccount(id, index, callback) { var self = this; var key = id + '/' + index; @@ -894,6 +910,12 @@ WalletDB.prototype.saveAddress = function saveAddress(id, addresses, callback) { }); }; +/** + * Retrieve paths by hash. + * @param {Hash} hash + * @param {Function} callback + */ + WalletDB.prototype._getPaths = function _getPaths(hash, callback) { var self = this; var paths;