Add watchlast option to limit initially watched addresses #2196
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Very large wallets have many addresses that may not be needed anymore, but these addresses were always being loaded into the address transaction filters (cfilters in SPV mode, and given to dcrd to watch when running in full node mode). To improve startup resource usage and performance, add a new watchlast option that counts backwards from the current address index of every HD account branch, and ignores loading addresses prior to the cutoff during the initial sync.
Future iterations on this idea may allow custom values for different accounts and branches, or perhaps something automatic for mixed accounts where we don't expect old addresses to ever be used again, but for now this seems good enough.