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

Truncate inbound Peers response further #3007

Merged
merged 2 commits into from
Nov 2, 2021

Conversation

oxarbitrage
Copy link
Contributor

Motivation

We want to truncate the number of peers we return to a Peers request by a fraction of available peer addresses.

Closes #1889

Solution

Truncate to whatever is smaller: The bitcoin constant(1000) or 1/3 of the number of available peers. We use ceil() instead of floor() to cover edge cases of 1 and 2.

Review

Anyone can review. A test could be possible, i made one. It was a mix of what https://github.com/ZcashFoundation/zebra/blob/main/zebra-network/src/peer_set/initialize/tests/vectors.rs and https://github.com/ZcashFoundation/zebra/blob/main/zebrad/src/components/inbound/tests.rs. There is some work to be done so we don't duplicate code, some files will have to change into public (which requires documentation), etc. I think doesn't worth it, just to see if we are truncating in a good manner.

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

zebrad/src/components/inbound.rs Show resolved Hide resolved
@oxarbitrage oxarbitrage enabled auto-merge (squash) November 2, 2021 22:07
@oxarbitrage oxarbitrage merged commit 4d600a0 into ZcashFoundation:main Nov 2, 2021
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.

Zebra should limit the number of addresses it sends to peers, to avoid address book discovery
2 participants