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

Move initial rescan to global syncer loop #2301

Merged
merged 4 commits into from
Nov 17, 2023
Merged

Conversation

matheusd
Copy link
Member

This moves the initial account and address discovery and rescan from the per-peer startup procedure to the global syncer startup sync procedure.

This makes the code easier to reason about and removes the need for the atomic lock to the discoverAccounts field.

The previous code would execute a rescan after every connected peer, if it had any new headers that connected to the main chain. With the changes in this commit, the syncer now only performs the full rescan once at startup and relies on the header announcement logic to scan when new blocks are relayed from peers after the initial sync.

It also finishes switching all backend functions in SPV to use waitForRemotes and removes unneeded functions.

Part of #2289

This makes the Blocks backend function wait until the backend has peers
instead of returning with ErrNoPeers.

This makes this function safe to be used in the face of flaky connection
to peers.
This is more reliable as it ensures the function is blocked until either
a peer is connected or the context closes without a busy wait.
This moves the initial account and address discovery and rescan from the
per-peer startup procedure to the global syncer startup sync procedure.

This makes the code easier to reason about and removes the need for the
atomic lock to the discoverAccounts field.

The previous code would execute a rescan after every connected peer, if
it had any new headers that connected to the main chain.  With the
changes in this commit, the syncer now only performs the full rescan
once at startup and relies on the header announcement logic to scan when
new blocks are relayed from peers after the initial sync.
@jrick jrick merged commit 284762f into decred:master Nov 17, 2023
2 checks passed
@matheusd matheusd deleted the global-rescan branch November 17, 2023 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants