You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(dash-spv): slow-peer swap on refactor/network-mod adds a peer without emitting PeerConnected #1218
On refactor/network-mod (#902), the peer supervisor's slow-peer swap adds the incoming peer to the connected set without sending NetworkEvent::PeerConnected. Only the displaced peer gets its PeerDisconnected. The other two accept paths (free slot, last-resort) both send PeerConnected.
dash-spv/src/network/manager.rs at 748816fe, the else if let Some(pos) = slow branch:
let new_addr = peer.addr();let old = peers.swap_remove(pos);
peers.push(peer);
replaced = Some(new_addr);Some(old)
Impact
Everything keyed on PeerConnected never learns about a swapped-in peer:
BlockHeadersManager never announces our tip to it (the GetHeaders sent to new peers once synced), so it keeps sending inv instead of header announcements.
MempoolManager never activates it, so its mempool transactions are missed.
The FFI on_peer_connected callback never fires, so apps under-count peers.
When that peer later disconnects, PeerDisconnected arrives for an address consumers never saw connect.
Evidence
Testnet full sync, run 2 of a dev vs refactor/network-mod benchmark (2026-10-26):
That peer delivered 62.5 MB over 140s with no NetworkEvent: PeerConnected(68.67.122.71:19999) anywhere in the log.
Fix
Send NetworkEvent::PeerConnected(new_addr) in the swap branch, next to the PeerDisconnected(old_addr) that follows it. A test that drives a swap and asserts both events would pin it down.
Related
The same runs show PeerDisconnected for addresses not connected at the time: 49 disconnect events against 16 connections in one run, 35 of them for peers that were not connected. Consumers counting disconnects as dropped connections are misled. That may deserve its own fix.
Activity
fix(dash-spv): announce the peer a slow-peer swap brings in