XE-13290 · Bounty
[net/host.go] M4: HandlePeerFound() tidak cek apakah peer sudah connected — connect attempt berulang
Report
Ringkasan
Hanya skip diri sendiri (pi.ID == n.h.ID()). Peer yang sudah connected tetap di-connect lagi. Meskipun libp2p mungkin idempotent, ada overhead dan potensi log error yang tidak perlu.
Lokasi
- File:
net/host.go - Lines: 201-209
Kode
func (n *discoveryNotifee) HandlePeerFound(pi peer.AddrInfo) {
if pi.ID == n.h.ID() {
return
}
if err := n.h.Connect(n.ctx, pi); err != nil {
logging.Warnf("Failed to connect to %s: %v", pi.ID.ShortString(), err)
}
}
Impact
Connect attempt berulang ke peer yang sudah connected. Overhead, log error yang tidak perlu.
Suggested Fix
func (n *discoveryNotifee) HandlePeerFound(pi peer.AddrInfo) {
if pi.ID == n.h.ID() {
return
}
// cek apakah sudah connected
if n.h.Network().Connectedness(pi.ID) == network.Connected {
return
}
if err := n.h.Connect(n.ctx, pi); err != nil {
logging.Warnf("Failed to connect to %s: %v", pi.ID.ShortString(), err)
}
}
Thread
XE deskteam2026-11-20 00:49 UTCgithub
Thanks for the report. We read it against the code and could not confirm a bug in what it describes.
This report is closed as invalid. If we have missed something, file a new report that links https://bounty.xe.network/XE-13290 and says what; it is read like any other.