walletdb: better getAccounts.
This commit is contained in:
parent
86e1e35f9a
commit
8d624f1b0e
@ -970,30 +970,17 @@ WalletDB.prototype.getAccount = co(function* getAccount(wid, index) {
|
||||
*/
|
||||
|
||||
WalletDB.prototype.getAccounts = co(function* getAccounts(wid) {
|
||||
var map = [];
|
||||
var i, items, item, name, index, accounts;
|
||||
var i, items;
|
||||
|
||||
items = yield this.db.range({
|
||||
gte: layout.i(wid, '\x00'),
|
||||
lte: layout.i(wid, '\xff')
|
||||
items = yield this.db.values({
|
||||
gte: layout.n(wid, 0x00000000),
|
||||
lte: layout.n(wid, 0xffffffff)
|
||||
});
|
||||
|
||||
for (i = 0; i < items.length; i++) {
|
||||
item = items[i];
|
||||
name = layout.ii(item.key)[1];
|
||||
index = item.value.readUInt32LE(0, true);
|
||||
map[index] = name;
|
||||
}
|
||||
for (i = 0; i < items.length; i++)
|
||||
items[i] = items[i].toString('ascii');
|
||||
|
||||
// Get it out of hash table mode.
|
||||
accounts = [];
|
||||
|
||||
for (i = 0; i < map.length; i++) {
|
||||
assert(map[i] != null);
|
||||
accounts.push(map[i]);
|
||||
}
|
||||
|
||||
return accounts;
|
||||
return items;
|
||||
});
|
||||
|
||||
/**
|
||||
@ -1291,6 +1278,7 @@ WalletDB.prototype.getWallets = function getWallets() {
|
||||
/**
|
||||
* Encrypt all imported keys for a wallet.
|
||||
* @param {WalletID} wid
|
||||
* @param {Buffer} key
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
@ -1324,6 +1312,7 @@ WalletDB.prototype.encryptKeys = co(function* encryptKeys(wallet, key) {
|
||||
/**
|
||||
* Decrypt all imported keys for a wallet.
|
||||
* @param {WalletID} wid
|
||||
* @param {Buffer} key
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user