-
Notifications
You must be signed in to change notification settings - Fork 3
reconnect with backoff #42
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
Conversation
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]>
There was a problem hiding this 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]>
kamilsa
left a comment
There was a problem hiding this 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]>