Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet: --preload-all option to load all wallet on open. #803

Merged
merged 3 commits into from
Dec 4, 2023

Conversation

nodech
Copy link
Contributor

@nodech nodech commented Jan 20, 2023

In some cases loading wallet lazily is not good enough. if wallet open takes some time (e.g. because of the plugin) - first http request to the wallet will be responsible for opening the wallet. This PR allows users to load all wallets before HTTP service is started, guaranteeing the wallet will be available before starting HTTP server.

By default this is set to false.

@nodech nodech added quick review difficulty - easy wallet part of the codebase breaking-minor Backwards compatible - Release version labels Jan 20, 2023
@nodech nodech requested a review from pinheadmz January 20, 2023 17:55
@coveralls
Copy link

coveralls commented Jan 20, 2023

Coverage Status

coverage: 68.546% (-0.003%) from 68.549% when pulling b12650d on nodech:preload-wallets into bb7da60 on handshake-org:master.

@nodech nodech force-pushed the preload-wallets branch 2 times, most recently from 2f5576c to a2e16d5 Compare January 26, 2023 14:20
@nodech nodech added this to the hsd 7.0.0 milestone Aug 1, 2023
@nodech nodech marked this pull request as draft August 4, 2023 16:14
@nodech nodech marked this pull request as ready for review October 20, 2023 11:07
@rithvikvibhu
Copy link
Member

This with a new data dir seems to error:

hsd --prefix /tmp/hsd_3 --network regtest --wallet-preload-all
[...snip...]
[info] (wallet) Opening WalletDB...
[info] (wallet-migrations) Fresh start, saving last migration id: 3
[info] (wallet) WalletDB is loading (depth=0, height=0, start=0).
[info] (wallet) Created account primary/default/0.
[info] (wallet) Wallet initialized (primary).
[info] (wallet) Created wallet primary in WalletDB.
[info] (wallet) Loaded primary wallet (id=primary, wid=0, address=rs1qmx3ulagg84y5jc3prga2zv4lf66weaqw6qdywh)
[info] (wallet) Preloading all wallets...
TypeError: Invalid type for database key.
    at Object.write (/media/data/Projects/handshake/hsd/node_modules/bdb/lib/key.js:98:7)
    at BaseKey.encode (/media/data/Projects/handshake/hsd/node_modules/bdb/lib/key.js:398:20)
    at Key.encode (/media/data/Projects/handshake/hsd/node_modules/bdb/lib/key.js:478:22)
    at WalletDB.getID (/media/data/Projects/handshake/hsd/lib/wallet/walletdb.js:958:45)
    at WalletDB._get (/media/data/Projects/handshake/hsd/lib/wallet/walletdb.js:1000:27)
    at WalletDB.preloadAll (/media/data/Projects/handshake/hsd/lib/wallet/walletdb.js:276:18)
    at async WalletDB.open (/media/data/Projects/handshake/hsd/lib/wallet/walletdb.js:241:5)
    at async Plugin.open (/media/data/Projects/handshake/hsd/lib/wallet/plugin.js:92:5)
    at async FullNode.openPlugins (/media/data/Projects/handshake/hsd/lib/node/node.js:475:9)
    at async FullNode.open (/media/data/Projects/handshake/hsd/lib/node/fullnode.js:298:5)

@rithvikvibhu
Copy link
Member

Looks like normal load calls getID with 0, and preloadAll calls it with primary:

[info] (wallet) WalletDB is loading (depth=1, height=0, start=0).
wdb.getID got wid: 0
[info] (wallet) Wallet opened (primary).
[info] (wallet) Loaded primary wallet (id=primary, wid=0, address=rs1qmx3ulagg84y5jc3prga2zv4lf66weaqw6qdywh)
[info] (wallet) Preloading all wallets...
wdb.getID got wid: primary
TypeError: Invalid type for database key.

@nodech nodech merged commit 7999477 into handshake-org:master Dec 4, 2023
1 of 6 checks passed
@nodech nodech deleted the preload-wallets branch December 4, 2023 11:06
@nodech nodech mentioned this pull request Nov 29, 2024
@nodech nodech mentioned this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-minor Backwards compatible - Release version quick review difficulty - easy wallet part of the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants