fix getAccounts.
This commit is contained in:
parent
1e1bd82355
commit
350c76d49b
@ -81,7 +81,7 @@ function runBench(callback) {
|
||||
});
|
||||
}, function(err) {
|
||||
assert.ifError(err);
|
||||
end(10000);
|
||||
end(100000);
|
||||
next();
|
||||
});
|
||||
end = bench('tx');
|
||||
|
||||
@ -705,7 +705,8 @@ WalletDB.prototype._getAccount = function getAccount(id, index, callback) {
|
||||
*/
|
||||
|
||||
WalletDB.prototype.getAccounts = function getAccounts(id, callback) {
|
||||
var accounts = [];
|
||||
var map = [];
|
||||
var i, accounts;
|
||||
|
||||
if (!utils.isAlpha(id))
|
||||
return callback(new Error('Wallet IDs must be alphanumeric.'));
|
||||
@ -717,13 +718,20 @@ WalletDB.prototype.getAccounts = function getAccounts(id, callback) {
|
||||
parse: function(value, key) {
|
||||
var name = key.split('/')[2];
|
||||
var index = value.readUInt32LE(0, true);
|
||||
assert(index === accounts.length);
|
||||
accounts.push(name);
|
||||
map[index] = name;
|
||||
}
|
||||
}, function(err) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
// Get it out of hash table mode.
|
||||
accounts = new Array(map.length);
|
||||
|
||||
for (i = 0; i < map.length; i++) {
|
||||
assert(map[i] != null);
|
||||
accounts[i] = map[i];
|
||||
}
|
||||
|
||||
return callback(null, accounts);
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user