Skip to content

Commit

Permalink
wallet: connect to node and load filter only after walletdb finished …
Browse files Browse the repository at this point in the history
…loading..
  • Loading branch information
nodech committed Jan 26, 2023
1 parent a1dd9a3 commit 2f5576c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
7 changes: 3 additions & 4 deletions lib/wallet/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ class Wallet extends EventEmitter {
const account = await this._createAccount(options, passphrase);
assert(account);

this.logger.info('Wallet initialized (%s).', this.id);
await this.txdb.open(this);

return this.txdb.open(this);
this.logger.info('Wallet initialized (%s).', this.id);
}

/**
Expand All @@ -215,9 +215,8 @@ class Wallet extends EventEmitter {
if (!account)
throw new Error('Default account not found.');

await this.txdb.open(this);
this.logger.info('Wallet opened (%s).', this.id);

return this.txdb.open(this);
}

/**
Expand Down
19 changes: 10 additions & 9 deletions lib/wallet/walletdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,6 @@ class WalletDB extends EventEmitter {
if (this.options.wipeNoReally)
await this.wipe();

await this.watch();
await this.connect();

this.logger.info(
'WalletDB loaded (depth=%d, height=%d, start=%d).',
this.depth,
this.state.height,
this.state.startHeight);

const wallet = await this.ensure({
id: 'primary'
});
Expand All @@ -227,6 +218,16 @@ class WalletDB extends EventEmitter {

await this.checkLookahead();
await this.preloadAll();

await this.watch();
await this.connect();

this.logger.info(
'WalletDB loaded (depth=%d, height=%d, start=%d).',
this.depth,
this.state.height,
this.state.startHeight);

}

/**
Expand Down

0 comments on commit 2f5576c

Please sign in to comment.