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

p2p: exclude self from GetPeers results #6132

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions network/p2pNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,9 @@
const maxNodes = 100
addrInfos := n.pstore.GetAddresses(maxNodes, phonebook.PhoneBookEntryRelayRole)
for _, peerInfo := range addrInfos {
if peerInfo.ID == n.service.ID() {
continue

Check warning on line 646 in network/p2pNetwork.go

View check run for this annotation

Codecov / codecov/patch

network/p2pNetwork.go#L645-L646

Added lines #L645 - L646 were not covered by tests
}
if peerCore, ok := addrInfoToWsPeerCore(n, peerInfo); ok {
peers = append(peers, &peerCore)
}
Expand All @@ -666,6 +669,9 @@
for _, addrInfo := range infos {
// TODO: remove after go1.22
info := addrInfo
if info.ID == n.service.ID() {
continue

Check warning on line 673 in network/p2pNetwork.go

View check run for this annotation

Codecov / codecov/patch

network/p2pNetwork.go#L673

Added line #L673 was not covered by tests
}
if peerCore, ok := addrInfoToWsPeerCore(n, &info); ok {
peers = append(peers, &peerCore)
}
Expand Down
Loading