Skip to content

Conversation

@glottologist
Copy link
Contributor

Describe the changes
Before:
P2P client made unbounded requests to failing peers.

After:
Implements circuit breaker pattern for peer connections. Failed peers are temporarily isolated, preventing cascade failures and improving network resilience.

Changes

Circuit Breaker Implementation

  • Added CircuitBreakerManager<K> with atomic state management and capacity enforcement
  • Three states: Closed (normal), Open (blocked after threshold failures), HalfOpen (testing recovery)
  • Configurable failure threshold (5), cooldown duration (30s), and recovery attempts (3)

P2P Integration

  • GossipClient tracks circuit breakers per peer mining address
  • check_health() returns false when circuit is open
  • Data retrieval operations (get_data, pull_data) check circuit breaker before requests
  • Success/failure recorded on all peer interactions to update circuit state

Related Issue(s)
Please link to the issue(s) that will be closed with this PR.

Checklist

  • Tests have been added/updated for the changes.
  • Documentation has been updated for the changes (if applicable).
  • The code follows Rust's style guidelines.

Additional Context
Add any other context about the pull request here.

@glottologist glottologist force-pushed the jason/gossip-circuit-breaker branch from b738cb6 to 5e94f7e Compare November 10, 2025 11:38
@glottologist glottologist marked this pull request as ready for review November 10, 2025 12:07
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.

2 participants