-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
netsync: don't ask for blocks from peers on the same block height #2304
base: master
Are you sure you want to change the base?
netsync: don't ask for blocks from peers on the same block height #2304
Conversation
Pull Request Test Coverage Report for Build 12803849581Details
💛 - Coveralls |
When we're all caught up and we have a new peer, we'll ask for blocks from peers that we're on the same height. Since these peers don't have any blocks to send us, they don't reply and we disconnect from them as they timeout. To prevent this, we don't ask for blocks if the chain thinks we're current and do not have a peer that reports having a higher block.
fb9121d
to
aace7a9
Compare
cc: @ziggie1984 for review |
@@ -309,6 +309,11 @@ func (sm *SyncManager) startSync() { | |||
higherPeers = append(higherPeers, peer) | |||
} | |||
|
|||
if sm.chain.IsCurrent() && len(higherPeers) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it matter if we are current or not? I think as long as we have no higherPeers
there's no need to sync? As these peers don't have any blocks to send us, they don't reply and we disconnect from them as they timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter but if the node is getting eclipse attacked, then it may be that it's not current and it doesn't have any higher peers. Thought it might be good to differentiate because of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM❤️
When we're all caught up and we have a new peer, we'll ask for blocks from peers that we're on the same height. Since these peers don't have any blocks to send us, they don't reply and we disconnect from them as they timeout.
To prevent this, we don't ask for blocks if the chain thinks we're current and do not have a peer that reports having a higher block.