All Known Implementing Classes:
KRPC, TorrentKRPC

public interface DHT
Stub for KRPC.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    announce(byte[] ih, boolean isSeed)
    Announce to ourselves.
    void
    announce(byte[] ih, byte[] peerHash, boolean isSeed)
    Announce somebody else we know about to ourselves.
    int
    announce(byte[] ih, int max, long maxWait, boolean isSeed)
    Announce to the closest DHT peers.
    getPeersAndAnnounce(byte[] ih, int max, long maxWait, int annMax, long annMaxWait, boolean isSeed, boolean noSeeds)
    Fetch peers for a torrent, and announce to the closest annMax nodes we find.
    int
    The UDP query port.
    int
    The UDP response port.
    void
    ping(Destination dest, int port)
    Ping.
    Debug info, HTML formatted.
    int
    Known nodes, not estimated total network size.
    void
    Stop everything.
    void
    unannounce(byte[] ih)
    Remove reference to ourselves in the local tracker.
  • Method Details

    • getPort

      int getPort()
      The UDP query port.
      Returns:
      The UDP query port
    • getRPort

      int getRPort()
      The UDP response port.
      Returns:
      The UDP response port
    • ping

      void ping(Destination dest, int port)
      Ping. We don't have a NID yet so the node is presumed to be absent from our DHT. Non-blocking, does not wait for pong. If and when the pong is received the node will be inserted in our DHT.
      Parameters:
      dest - the destination to ping
      port - the UDP port to ping
    • getPeersAndAnnounce

      Collection<Hash> getPeersAndAnnounce(byte[] ih, int max, long maxWait, int annMax, long annMaxWait, boolean isSeed, boolean noSeeds)
      Fetch peers for a torrent, and announce to the closest annMax nodes we find. Blocking! Caller should run in a thread.
      Parameters:
      ih - the Info Hash (torrent)
      max - maximum number of peers to return
      maxWait - the maximum time to wait (ms) must be > 0
      annMax - the number of peers to announce to
      annMaxWait - the maximum total time to wait for announces, may be 0 to return immediately without waiting for acks
      isSeed - true if seed, false if leech
      noSeeds - true if we do not want seeds in the result
      Returns:
      possibly empty (never null)
    • announce

      void announce(byte[] ih, boolean isSeed)
      Announce to ourselves. Non-blocking.
      Parameters:
      ih - the Info Hash (torrent)
      isSeed - true if seed, false if leech
    • announce

      void announce(byte[] ih, byte[] peerHash, boolean isSeed)
      Announce somebody else we know about to ourselves. Non-blocking.
      Parameters:
      ih - the Info Hash (torrent)
      peerHash - the peer's Hash
      isSeed - true if seed, false if leech
    • unannounce

      void unannounce(byte[] ih)
      Remove reference to ourselves in the local tracker. Use when shutting down the torrent locally. Non-blocking.
      Parameters:
      ih - the Info Hash (torrent)
    • announce

      int announce(byte[] ih, int max, long maxWait, boolean isSeed)
      Announce to the closest DHT peers. Blocking unless maxWait <= 0 Caller should run in a thread. This also automatically announces ourself to our local tracker. For best results do a getPeers() first so we have tokens.
      Parameters:
      ih - the Info Hash (torrent)
      max - maximum number of peers to announce to
      maxWait - the maximum total time to wait (ms) or 0 to do all in parallel and return immediately.
      isSeed - true if seed, false if leech
      Returns:
      the number of successful announces, not counting ourselves.
    • stop

      void stop()
      Stop everything.
    • size

      int size()
      Known nodes, not estimated total network size.
      Returns:
      the number of known nodes in the DHT
    • renderStatusHTML

      String renderStatusHTML()
      Debug info, HTML formatted.
      Returns:
      HTML string with DHT status information