running_node: don't ask for blocks until utreexo peers announce it #442
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.
What is the purpose of this pull request?
Which crates are being modified?
Description
Currently, if we are notified for a new block, we ask for headers and
then try to download the actual data. One problem may emerge if our
utreexo peers haven't seen the block (or are still processing it). We
may ask for a block that they don't have, making them take too long to
respond and get punished for it. Eventually, we will ban all our utreexo
peers, thanks to that.
This commit changes that logic to only attempt to download a new block
iff it gets announced by our utreexo peers; or if a while has passed
without anything new (in this case our utreexo peers may be withholding a block from us).
Also remove some duplicate code on
sync_node.Notes to the reviewers
Most of these bugs appears after leaving it running for a couple of days
Checklist
just lintcargo test