shouldCompact method

bool shouldCompact(
  1. String roomId,
  2. int logLength
)

Whether the client currently being answered should be asked to upload a snapshot for roomId, given the current logLength.

Returning true stamps the rate limit for roomId.

Implementation

bool shouldCompact(String roomId, int logLength) {
  if (logLength <= _logCompactThreshold) {
    return false;
  }

  final askedAt = _compactAskedAt[roomId];
  if (askedAt != null && _now().difference(askedAt) < _retryInterval) {
    return false;
  }

  _compactAskedAt[roomId] = _now();
  return true;
}