fix: fix the status marking problem of header sync #2857
Merged
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.
There has always been a problem with the header sync protocol. When only the sync protocol is enabled, there may be a relatively large delay in obtaining the latest block. This is caused by incorrect state marking. This PR introduces a new state. Try to fix this problem.
The action of header sync is not completed at one time. It needs to be updated in real-time during the entire connection process. It cannot be considered that this node is always at the highest just because it is synchronized to the highest one time. That is to say, the completed state of sync should be dynamically converted to need sync again.
The
TipSynced
status indicates that this node has synchronized the headers and will try to synchronize again after 28s. At the same time, such a node can be used as the request object ofGetblocks
Suspend
andTipSynced
are not exactly the same. Suspend thinks that the node may have some problems, such as being in the ibd state and suspending the sync request to it. Such a node cannot be used as the request object of the sync block, and it does not need to be based on the frequency of the block time to detection status