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

Enable API Before Sync and Return 503 When Not Synced #1155

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

cranycrane
Copy link

Description:

This PR introduces two changes to improve API behavior during synchronization:

  1. Return HTTP 503 When Not Synced
    API endpoints now return a 503 status if Blockbook is unsynced, helping clients detect incomplete synchronization. Status of the Blockbook in the response was preserved.

  2. Allow API Access Before Sync Completes
    Added an enableAPIBeforeSync flag to optionally allow API access before full sync, useful in read-only scenarios.

Changes:

Updated jsonHandler to return 503 if not synced.
Added enableAPIBeforeSync flag for optional API access during sync.

Impact:

Improves API flexibility for clients by providing better control over sync-dependent responses.

@cranycrane cranycrane marked this pull request as ready for review November 9, 2024 15:35
@cranycrane
Copy link
Author

@martinboehm hello, can you please take a look at this?

@martinboehm
Copy link
Contributor

Sorry, I cannot accept the pull request, for the following reasons:

  1. I think it is very bad idea to enable public interface when Blockbook is in bulk sync mode. The database is in this case in an inconsistent state and the results are unpredictable
  2. the detection of the sync mode is done in a very costly way. You are calling api.GetSystemInfo, which internally calls backend. And this is done for every single API call. You could instead use s.is.InitialSync to detect initial sync state. However with a current refactor it is a bit more complicated...
  3. there is a merge conflict, due to a refactor from our side

The handling of the initial sync state is not really an issue for us as we make our Blockbooks available only after they finish the syncing.

Also, please be aware that the PR has not complied with our contribution guide https://github.com/trezor/blockbook/blob/master/CONTRIBUTING.md

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