Skip to content

P2p: count connections without activity; use the counter when calculating next connection attempt time, to make it progressively bigger as the counter grows.#2026

Open
ImplOfAnImpl wants to merge 3 commits intop2p_pass_rng_to_peer_managerfrom
p2p_count_connections_without_activity
Open

P2p: count connections without activity; use the counter when calculating next connection attempt time, to make it progressively bigger as the counter grows.#2026
ImplOfAnImpl wants to merge 3 commits intop2p_pass_rng_to_peer_managerfrom
p2p_count_connections_without_activity

Conversation

@ImplOfAnImpl
Copy link
Contributor

If an outgoing connection gets closed without peer having done any activity (which means it didn't sent us any message except for WillDisconnect), peer address's connections_without_activity_count will be incremented. This counter is then used in AddressData::next_connect_time the same way as the already existing fail_count is - the bigger the counter, the longer the time before the next connection is attempted.

I.e. if the node gets banned by a peer (which doesn't necessarily mean that there is something wrong with the node, e.g. the fork detection script uses banning to prevent connecting to the same nodes every time), the current behavior is that the node will relentlessly try connecting to the peer every 10 seconds or so. The new behavior is that the delay before the next connection attempt will gradually increase as the counter grows, up to the maximum (which is currently 1h for non-
reserved peers).

Note:

  • Unlike fail_count, connections_without_activity_count won't cause the peer address to become Unreachable eventually.
  • Like fail_count, connections_without_activity_count is not stored in the peer db on disk; it only exists in memory and will be zero again when the node is restarted.

…lculating `next_connect_time` the same way `fail_count` has been used.
…ce instead of sending `TransactionSyncMessageTag`/`BlockSyncMessageTag` on each sync message. Add a test to check that the message is actually sent. Some renaming.
@ImplOfAnImpl ImplOfAnImpl force-pushed the p2p_count_connections_without_activity branch from 1ceaf37 to 5666d88 Compare March 13, 2026 09:36
@ImplOfAnImpl ImplOfAnImpl marked this pull request as ready for review March 13, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant