recordFailure method

void recordFailure(
  1. String relayUrl
)

Record a failed connection attempt to a relay.

Implementation

void recordFailure(String relayUrl) {
  final failures = (_failureCount[relayUrl] ?? 0) + 1;
  _failureCount[relayUrl] = failures;

  final health = _relayHealth[relayUrl];
  if (health != null) {
    final isHealthy = failures < maxFailureThreshold;
    _relayHealth[relayUrl] = health.copyWith(
      isHealthy: isHealthy,
      lastCheckedAt: DateTime.now(),
    );

    if (!isHealthy) {
      logger.log(
        'Relay $relayUrl marked as unhealthy after $failures failures',
      );
    }
  }
}