Respond with an empty headers list if in IBD state #1258
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.
Closes bullets 5 and 6 in #1199
v1 logic: ignore headers list request. If the node that requested headers receives blocks request in assumes that the peer is in Initial Block Download state and won't disconnect it as stalled.
new v2 logic: if in IBD respond with an empty list. It's simple and effective. Empty headers list is legal and no assumptions are made. Bitcoin does the same. Todos suggested some advanced logic with exchanging best block on handshake or some permission system. Idk it looks too complicated. Empty list does the job + serves as a pong.
P.S. also in v2 I moved call to the
wait_for_clock_diff
to allow more checks to pass before waiting.