class PeerReputation {

  public Optional<DisconnectReason> recordUselessResponse(final long timestamp) {
    uselessResponseTimes.add(timestamp);
    while (shouldRemove(uselessResponseTimes.peek(), timestamp)) {
      uselessResponseTimes.poll();
    }
    if (uselessResponseTimes.size() >= USELESS_RESPONSE_THRESHOLD) {
      LOG.debug("Disconnection triggered by exceeding useless response threshold");
      return Optional.of(DisconnectReason.USELESS_PEER);
    } else {
      return Optional.empty();
    }
  }

}