-
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
ignore existing peers in DialPeersAsync #2327
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2327 +/- ##
===========================================
- Coverage 61.02% 60.99% -0.03%
===========================================
Files 197 197
Lines 16296 16302 +6
===========================================
- Hits 9945 9944 -1
- Misses 5490 5495 +5
- Partials 861 863 +2
|
p2p/switch.go
Outdated
if addr.Same(ourAddr) { | ||
|
||
if addr.Same(ourAddr) || sw.HasPeerWithAddress(addr) { | ||
sw.Logger.Debug("Ignore attempt to connect to an existing peer", "addr", addr) |
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.
Do we want a log message if you try to connect to yourself? If so, would that warrant its own message?
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 a biggie since it's Debug
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, just a minor comment about log messages
[breaking] remove Switch#IsDialing
to be consistent with other usages of addrBook across Switch
ad93b8d
to
a00f0bf
Compare
Refactored code a little bit. PTAL |
if addr.Same(ourAddr) { | ||
sw.Logger.Debug("Ignore attempt to connect to ourselves", "addr", addr, "ourAddr", ourAddr) | ||
return | ||
} else if sw.IsDialingOrExistingAddress(addr) { |
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.
This will help, but afaict it won't fix the issue in every case because dials can still be concurrent.
Fixes #2253