java.lang.Object
net.i2p.i2ptunnel.access.AccessCounter

class AccessCounterextends Object
Access attempt counter.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final List<Long>
    List of timestamps of each connection attempt.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new access counter.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    (package private) boolean
    isBreached(Threshold threshold, long now)
    Check if the given threshold has been breached.
    (package private) boolean
    purge(long olderThan)
    Purges old accesses from the list.
    (package private) void
    recordAccess(long now)
    Records that a connection attempt was made.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • accesses

      private final List<Long> accesses
      List of timestamps of each connection attempt.
  • Constructor Details

    • AccessCounter

      AccessCounter()
      Create a new access counter.
  • Method Details

    • recordAccess

      void recordAccess(long now)
      Records that a connection attempt was made.
      Parameters:
      now - the current time in milliseconds, as returned by Clock.now(), stored as this access's timestamp
    • isBreached

      boolean isBreached(Threshold threshold, long now)
      Check if the given threshold has been breached.
      Parameters:
      threshold - definition of a threshold
      now - the current time in milliseconds, as returned by Clock.now(), used to age recorded accesses against the threshold's window
      Returns:
      true if the given threshold has been breached
    • purge

      boolean purge(long olderThan)
      Purges old accesses from the list.
      Parameters:
      olderThan - remove all accesses older than the given timestamp
      Returns:
      true if there is nothing left in the access history