org.klomp.snark

## Interface BandwidthListener

- All Known Implementing Classes:
    BandwidthManager, Peer, PeerCoordinator, WebPeer

      public interface BandwidthListener

  Bandwidth and bandwidth limits

  Maintain three bandwidth estimators: Sent, received, and requested.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `downloaded(int size)` Called when bytes are unconditionally received.
    `long` | `getDownBWLimit()` Returns the current download bandwidth limit in bytes per second.
    `long` | `getDownloadRate()` Returns the average download rate in bytes per second.
    `long` | `getUpBWLimit()` Returns the current upload bandwidth limit in bytes per second.
    `long` | `getUploadRate()` Returns the average upload rate in bytes per second.
    `boolean` | `overDownBWLimit()` Checks if the current download bandwidth is over the limit.
    `boolean` | `overUpBWLimit()` Checks if the current upload bandwidth is over the limit.
    `boolean` | `shouldRequest(Peer peer, int size)` Checks if we should request the given number of bytes from a peer.
    `boolean` | `shouldSend(int size)` Checks if we should send the given number of bytes.
    `void` | `uploaded(int size)` Called when bytes are unconditionally sent.

- - ### Method Detail

    - #### downloaded

          void downloaded(int size)

      Called when bytes are unconditionally received.
      Parameters:
        `size` - the number of bytes received

    - #### getDownBWLimit

          long getDownBWLimit()

      Returns the current download bandwidth limit in bytes per second.
      Returns:
        the download limit in Bps

    - #### getDownloadRate

          long getDownloadRate()

      Returns the average download rate in bytes per second.
      Returns:
        the average download rate in Bps

    - #### getUpBWLimit

          long getUpBWLimit()

      Returns the current upload bandwidth limit in bytes per second.
      Returns:
        the upload limit in Bps

    - #### getUploadRate

          long getUploadRate()

      Returns the average upload rate in bytes per second.
      Returns:
        the average upload rate in Bps

    - #### overDownBWLimit

          boolean overDownBWLimit()

      Checks if the current download bandwidth is over the limit.
      Returns:
        true if over the download limit, false otherwise

    - #### overUpBWLimit

          boolean overUpBWLimit()

      Checks if the current upload bandwidth is over the limit.
      Returns:
        true if over the upload limit, false otherwise

    - #### shouldRequest

          boolean shouldRequest(Peer peer,
                                int size)

      Checks if we should request the given number of bytes from a peer.
      Parameters:
        `peer` - the peer to request from
        `size` - the number of bytes to request
      Returns:
        true if the request should be made, false otherwise

    - #### shouldSend

          boolean shouldSend(int size)

      Checks if we should send the given number of bytes. Do NOT call uploaded() if this returns true.
      Parameters:
        `size` - the number of bytes to send
      Returns:
        true if the bytes should be sent, false otherwise

    - #### uploaded

          void uploaded(int size)

      Called when bytes are unconditionally sent.
      Parameters:
        `size` - the number of bytes sent