Skip to content

Conversation

@turuslan
Copy link
Contributor

@turuslan turuslan commented Dec 9, 2025

  • reconnect when not enough peers
  • exponential backoff on disconnect and failed connect
  • reset backoff on successful connect

Signed-off-by: turuslan <[email protected]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements an automatic peer reconnection mechanism with exponential backoff to maintain stable network connectivity. The system now actively monitors peer connections and attempts to reconnect when peer counts drop below desired thresholds.

Key changes:

  • Adds state machine for peer lifecycle management (Connectable → Connecting → Connected → Backoff)
  • Implements exponential backoff strategy for failed connections with configurable min/max durations
  • Introduces periodic connection maintenance via 5-second timer loop

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
src/modules/networking/networking.hpp Defines PeerState struct with variant states, adds peer tracking members (peer_states_, connectable_peers_, random_), and declares connectToPeers() method
src/modules/networking/networking.cpp Implements connectToPeers() with backoff logic, updates bootnode initialization to populate peer states, adds backoff handling in disconnect handler, and establishes timer loop for periodic connection attempts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Copy link
Contributor

@kamilsa kamilsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more documentation to new methods and structures

Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
Signed-off-by: turuslan <[email protected]>
@kamilsa kamilsa merged commit 3a96a1f into master Dec 13, 2025
7 checks passed
@kamilsa kamilsa deleted the feature/reconnect branch December 13, 2025 07:11
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.

3 participants