Class PeerMessageLimiter


  • public class PeerMessageLimiter
    extends java.lang.Object
    Handles incoming peer message counting/timing/stats in order to catch and block abusive peers.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.HashMap message_counts  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean countIncomingMessage​(java.lang.String message_id, int max_counts, int time_limit_ms)
      Add the reception of the given message to time-limited count.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • message_counts

        private final java.util.HashMap message_counts
    • Constructor Detail

      • PeerMessageLimiter

        public PeerMessageLimiter()
    • Method Detail

      • countIncomingMessage

        public boolean countIncomingMessage​(java.lang.String message_id,
                                            int max_counts,
                                            int time_limit_ms)
        Add the reception of the given message to time-limited count.
        Parameters:
        message_id - message to count
        max_counts - max counts allowed within the given time limit
        time_limit_ms - time in ms that the count limiting applies
        Returns:
        true if the added count is within acceptable time limits, false if there have been too many counts