Faster sync by collecting esplora ureq thread handles #579
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.
Description
Speeds up esplora ureq syncing. Taken from #560
The current sync just creates a map of scripts to joinhandles which doesn't yet spawn the sync threads due to lazy evaluation. In the following
handles.map()
, the thread handles are sequentially evaluated and joined. With the fix, the handles are collected so that the threads spawn in parallel, and then joinedNotes to the reviewers
I had to add a
#[allow(clippy::needless_collect)]
so that it wouldn't complain about collecting and then iterating. (Perhaps clippy is partially responsible for this issue!)Tested sync performance by doing a fresh sync on an existing gun wallet.
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingBugfixes: