Automatically set walletdb.spv according to client
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.
Codecov Report
Merging #621 into master will increase coverage by
0.21%. The diff coverage is100%.
@@ 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 dataPowered by Codecov. Last update 125e818...ce4bf1d. Read the comment docs.
This will crash on most common use case: WalletClient where wallet node runs separately, because WalletClient wont have node.
It now checks whether the node exists before touching its spv filter.
#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...
Sounds good. Should I redo this PR against your PR so that we keep the regression test as well?
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
Sounds good. Also take a look at #417, I've written an spvnode-test.js. It may be of help for your test.
@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.