Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.klomp.snark.dht
Interface DHT

    public interface DHT

Stub for KRPC

Method Summary
`void` | `announce(byte[] ih)` Announce to ourselves.
`void` | `announce(byte[] ih, byte[] peerHash)` Announce somebody else we know about.
`int` | `announce(byte[] ih, int max, long maxWait)` Announce to the closest DHT peers.
`List<Hash>` | `getPeers(byte[] ih, int max, long maxWait)` Get peers for a torrent.
`int` | `getPort()`
`void` | `ping(Destination dest, int port)` Ping.
`void` | `unannounce(byte[] ih)` Remove reference to ourselves in the local tracker.

Method Detail

### getPort

    int getPort()

  Returns:
    The UDP port that should be included in a PORT message.

### 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.

### getPeers

    List<Hash> getPeers(byte[] ih,
                        int max,
                        long maxWait)

  Get peers for a torrent. 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
  Returns:
    list or empty list (never null)

### announce

    void announce(byte[] ih)

  Announce to ourselves. Non-blocking.

  Parameters:
    `ih` - the Info Hash (torrent)

### announce

    void announce(byte[] ih,
                  byte[] peerHash)

  Announce somebody else we know about. Non-blocking.

  Parameters:
    `ih` - the Info Hash (torrent)
    `peerHash` - the peer's Hash

### 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)

  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)
    `maxWait` - the maximum total time to wait (ms) or 0 to do all in parallel and return immediately.
  Returns:
    the number of successful announces, not counting ourselves.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD