withSuccessfulRequest method

ProxyModel withSuccessfulRequest(
  1. int responseTime
)

Creates a new ProxyModel with an updated score after a successful request

Implementation

ProxyModel withSuccessfulRequest(int responseTime) {
  final newScore = (score ?? ProxyScore.initial()).recordSuccess(
    responseTime.toDouble(),
  );

  return ProxyModel(
    ip: ip,
    port: port,
    countryCode: countryCode,
    isHttps: isHttps,
    anonymityLevel: anonymityLevel,
    region: region,
    isp: isp,
    speed: speed,
    supportsWebsockets: supportsWebsockets,
    protocol: protocol,
    auth: auth,
    lastChecked: DateTime.now().millisecondsSinceEpoch,
    responseTime: responseTime,
    score: newScore,
  );
}