bcoin icon indicating copy to clipboard operation
bcoin copied to clipboard

Automatically set walletdb.spv according to client

Open OrfeasLitos opened this issue 7 years ago • 8 comments

This PR obviates the need for manually setting the 'spv' property of walletdb when the 'client' property is provided. The property is set to the same value as the client node. The original, manual way of setting the spv property is maintained for backwards compatibility, for walletdbs without a client and for manually overriding the client mode.

OrfeasLitos avatar Oct 17 '18 08:10 OrfeasLitos

Codecov Report

Merging #621 into master will increase coverage by 0.21%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #621      +/-   ##
==========================================
+ Coverage   53.32%   53.53%   +0.21%     
==========================================
  Files         104      109       +5     
  Lines       27666    27955     +289     
  Branches     4737     4748      +11     
==========================================
+ Hits        14752    14965     +213     
- Misses      12914    12990      +76
Impacted Files Coverage Δ
lib/wallet/walletdb.js 75.78% <100%> (+0.3%) :arrow_up:
lib/node/spvnode.js 48.11% <0%> (ø)
lib/wallet/index.js 100% <0%> (ø)
lib/wallet/node.js 18.42% <0%> (ø)
lib/bcoin.js 97.26% <0%> (ø)
lib/wallet/client.js 13.2% <0%> (ø)
lib/blockchain/chain.js 60.83% <0%> (+0.27%) :arrow_up:
lib/net/hostlist.js 31.04% <0%> (+0.27%) :arrow_up:
lib/node/http.js 39.64% <0%> (+0.5%) :arrow_up:
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 125e818...ce4bf1d. Read the comment docs.

codecov-io avatar Oct 17 '18 08:10 codecov-io

This will crash on most common use case: WalletClient where wallet node runs separately, because WalletClient wont have node.

nodech avatar Oct 17 '18 08:10 nodech

It now checks whether the node exists before touching its spv filter.

OrfeasLitos avatar Oct 17 '18 08:10 OrfeasLitos

#532 Might be a better solution to this issue - it covers all three wallet/node configuration (plugin, separate process and testing suite), and in all cases chain.spv (bool) is accessible. We could add a line to #532 that sets walletDB.spv based on that client info, if no options.spv is set...

pinheadmz avatar Apr 02 '19 18:04 pinheadmz

Sounds good. Should I redo this PR against your PR so that we keep the regression test as well?

OrfeasLitos avatar Apr 03 '19 10:04 OrfeasLitos

Hm yeah, I have one more update I need to do on that PR, which will include a spv-test.js hopefully we can get that merged, then follow up with your feature, and merge your test into that one. Will probably have that ready in a few days

pinheadmz avatar Apr 04 '19 00:04 pinheadmz

Sounds good. Also take a look at #417, I've written an spvnode-test.js. It may be of help for your test.

OrfeasLitos avatar Apr 04 '19 10:04 OrfeasLitos

@OrfeasLitos Ok #749 is a cleaner PR that just exposes prune and spv properties to the wallet, whether it's running as a plugin or standalone. Only problem is the info is unavailable until walletDB.open() gets the details from chain (it has to make an API call to the node server if running in standalone mode) but I think you could insert your check in open() as well.

pinheadmz avatar Apr 05 '19 19:04 pinheadmz