Skip to content

Commit

Permalink
wallet: properly resolve wallet ids.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Dec 4, 2023
1 parent b12650d commit 06d8fd1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/wallet/walletdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class WalletDB extends EventEmitter {
const wallets = await this.getWallets();

for (const wname of wallets)
await this._get(wname);
await this.get(wname);
}

/**
Expand Down Expand Up @@ -917,7 +917,7 @@ class WalletDB extends EventEmitter {
/**
* Map wallet id to wid.
* @param {String|Number} id
* @returns {Promise} - Returns {Number}.
* @returns {Promise<Number>}
*/

async ensureWID(id) {
Expand All @@ -933,7 +933,7 @@ class WalletDB extends EventEmitter {
/**
* Map wallet id to wid.
* @param {String} id
* @returns {Promise} - Returns {Number}.
* @returns {Promise<Number>}
*/

async getWID(id) {
Expand All @@ -950,7 +950,7 @@ class WalletDB extends EventEmitter {
/**
* Map wallet wid to id.
* @param {Number} wid
* @returns {Promise} - Returns {String}.
* @returns {Promise<String?>}
*/

async getID(wid) {
Expand All @@ -965,7 +965,7 @@ class WalletDB extends EventEmitter {
/**
* Get a wallet from the database, setup watcher.
* @param {Number|String} id
* @returns {Promise} - Returns {@link Wallet}.
* @returns {Promise<Wallet?>}
*/

async get(id) {
Expand All @@ -987,10 +987,11 @@ class WalletDB extends EventEmitter {
* Get a wallet from the database without a lock.
* @private
* @param {Number} wid
* @returns {Promise} - Returns {@link Wallet}.
* @returns {Promise<Wallet?>}
*/

async _get(wid) {
console.trace('Getting: ', wid);
const cache = this.wallets.get(wid);

if (cache)
Expand Down Expand Up @@ -2676,6 +2677,11 @@ function fromString(str) {
return buf;
}

/**
* @param {Buffer} buf
* @returns {String}
*/

function toString(buf) {
assert(buf.length > 0);
assert(buf[0] === buf.length - 1);
Expand Down

0 comments on commit 06d8fd1

Please sign in to comment.