-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
p2p: (seed mode) limit the number of attempts to connect to a peer #3573
Conversation
Fixes #3532 by storing a number of attempts we've tried to connect in-memory and removing the address from addrbook when number of attempts > 16
markAddrInBookBasedOnErr(addr, r.book, err) | ||
if _, ok := err.(p2p.ErrSwitchAuthenticationFailure); ok { | ||
switch err.(type) { | ||
case p2p.ErrSwitchAuthenticationFailure: |
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.
Not directly related to this PR but can we include a test for this path too?
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.
Looks straightforward and includes a proper test 🎉 LGTM
Co-Authored-By: melekes <anton.kalyaev@gmail.com>
Codecov Report
@@ Coverage Diff @@
## develop #3573 +/- ##
===========================================
+ Coverage 64.01% 64.15% +0.13%
===========================================
Files 213 213
Lines 17381 17354 -27
===========================================
+ Hits 11127 11134 +7
+ Misses 5323 5297 -26
+ Partials 931 923 -8
|
err := r.dialPeer(addr) | ||
if err != nil { | ||
switch err.(type) { | ||
case errMaxAttemptsToDial: |
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.
we can put multiple cases on the same line if the handling is the same:
case errMaxAttemptsToDial, errTooEarlyToDial:
Also, why not move all this into the dialPeer method?
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.
I needed this method to indicate whenever dialing was successful or not. I can refactor it to return (success bool)
and move logging into the method itself (if needed)
…endermint#3573) * use dialPeer function in a seed mode Fixes tendermint#3532 by storing a number of attempts we've tried to connect in-memory and removing the address from addrbook when number of attempts > 16
Fixes #3532