Packages that use Peer
Package
Description
I2P version of the Snark BitTorrent client, enhanced for I2P: peers are I2P destinations, torrents can be served anonymously as hidden services, and metadata carries I2P-specific comment fields.
The I2PSnark web interface (i2psnark.war): servlets and helpers for torrent management, file browsing and configuration.
  • Uses of Peer in org.klomp.snark

    Subclasses of Peer in org.klomp.snark
    Modifier and Type
    Class
    Description
    (package private) class 
    BEP 19.
    Classes in org.klomp.snark that implement interfaces with type arguments of type Peer
    Modifier and Type
    Class
    Description
    class 
    Represents a peer in the BitTorrent network, managing all public information and communication with that peer.
    Fields in org.klomp.snark declared as Peer
    Modifier and Type
    Field
    Description
    private final Peer
    PeerConnectionIn.peer
    The peer being read from.
    private final Peer
    PeerConnectionOut.peer
    The peer this connection serves.
    private final Peer
    PeerState.peer
    The peer this state describes.
    Fields in org.klomp.snark with type parameters of type Peer
    Modifier and Type
    Field
    Description
    (package private) final Deque<Peer>
    PeerCoordinator.peers
    Synchronize on this when changing peers or downloaders.
    private final Set<Peer>
    TrackerInfo.peers
    The peers from the response, unmodifiable and never null: a failure response has no peers, and is reported by TrackerInfo.getFailureReason() instead.
    Methods in org.klomp.snark that return Peer
    Modifier and Type
    Method
    Description
    private static Peer
    PeerCoordinator.peerIDInList(PeerID pid, Collection<Peer> peers)
    The peer with the given ID, or null.
    Methods in org.klomp.snark that return types with arguments of type Peer
    Modifier and Type
    Method
    Description
    Snark.getPeerList()
    The peer list.
    TrackerInfo.getPeers()
    Peers returned by the tracker.
    private static Set<Peer>
    TrackerInfo.getPeers(byte[] l, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util)
    One big string of concatenated 32-byte hashes.
    private static Set<Peer>
    TrackerInfo.getPeers(List<BEValue> l, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util)
    List of Dictionaries or List of Strings.
    private static Set<Peer>
    TrackerInfo.getPeers(Set<Hash> hashes, byte[] my_id, byte[] infohash, MetaInfo metainfo, I2PSnarkUtil util)
    From Hash to Peer.
    PeerCoordinator.peerList()
    Returns a snapshot of the connected peers list for web page detailed stats.
    Methods in org.klomp.snark with parameters of type Peer
    Modifier and Type
    Method
    Description
    boolean
    PeerCoordinator.addPeer(Peer peer)
    Add peer (inbound or outbound).
    boolean
    Piece.addPeer(Peer peer)
    Adds a peer to the set of peers that have this piece.
    int
    Peer.compareTo(Peer p)
    Compares this peer to another by PeerID, then by internal ID.
    void
    PeerCoordinator.connected(Peer peer)
    Called when a peer connection is established.
    void
    PeerListener.connected(Peer peer)
    Called when the connection to the peer has started and the handshake was successful.
    void
    PeerCoordinator.disconnected(Peer peer)
    Called when a peer disconnects.
    void
    PeerListener.disconnected(Peer peer)
    Called when the connection to the peer was terminated or the connection handshake failed.
    PeerCoordinator.getPartialPiece(Peer peer, int piece)
    Allocates a PartialPiece for a specific suggested piece, or returns null if the piece is not wanted, is already being fetched, or the peer is already fetching it.
    PeerCoordinator.getPartialPiece(Peer peer, BitField havePieces)
    Return partial piece to the PeerState if it's still wanted and peer has it.
    PeerCoordinator.getPartialPiece(Peer peer, BitField havePieces, Set<Integer> allowed)
    Return partial piece to the PeerState if it's still wanted and peer has it.
    PeerListener.getPartialPiece(Peer peer, int piece)
    Called when the peer suggests a specific piece via a BEP 6 suggest message.
    PeerListener.getPartialPiece(Peer peer, BitField havePieces)
    Called when a peer has connected and there may be a partially downloaded piece that the coordinatorator can give the peer task.
    PeerListener.getPartialPiece(Peer peer, BitField havePieces, Set<Integer> allowed)
    Called when a peer has connected and there may be a partially downloaded piece that the coordinator can give the peer task.
    boolean
    PeerCoordinator.gotBitField(Peer peer, BitField bitfield)
    Returns true if the given bitfield contains at least one piece we are interested in.
    boolean
    PeerListener.gotBitField(Peer peer, BitField bitfield)
    Called when a bitmap message is received.
    void
    PeerCoordinator.gotChoke(Peer peer, boolean choke)
    Called when a choke message is received.
    void
    PeerListener.gotChoke(Peer peer, boolean choke)
    Called when a choke message is received.
    void
    PeerCoordinator.gotCommentReq(Peer peer, int num)
    Called when comments are requested via ut_comment.
    void
    PeerListener.gotCommentReq(Peer peer, int num)
    Called when comments are requested via ut_comment.
    void
    PeerCoordinator.gotComments(Peer peer, List<Comment> comments)
    Called when comments are received via ut_comment.
    void
    PeerListener.gotComments(Peer peer, List<Comment> comments)
    Called when comments are received via ut_comment.
    void
    PeerCoordinator.gotExtension(Peer peer, int id, byte[] bs)
    PeerListener callback.
    void
    PeerListener.gotExtension(Peer peer, int id, byte[] bs)
    Called when an extension message is received.
    boolean
    PeerCoordinator.gotHave(Peer peer, int piece)
    Whether we still want the given piece.
    boolean
    PeerListener.gotHave(Peer peer, int piece)
    Called when a have piece message is received.
    void
    PeerCoordinator.gotInterest(Peer peer, boolean interest)
    Called when an interested message is received.
    void
    PeerListener.gotInterest(Peer peer, boolean interest)
    Called when an interested message is received.
    void
    PeerCoordinator.gotPeers(Peer peer, List<PeerID> peers)
    Handle peers from PEX; a PeerListener callback.
    void
    PeerListener.gotPeers(Peer peer, List<PeerID> pIDList)
    Called when peers are received via PEX.
    boolean
    PeerCoordinator.gotPiece(Peer peer, PartialPiece pp)
    Returns false if the piece is no good (according to the hash).
    boolean
    PeerListener.gotPiece(Peer peer, PartialPiece piece)
    Called when a piece is received from the peer.
    void
    PeerCoordinator.gotPort(Peer peer, int port, int rport)
    PeerListener callback Tell the DHT to ping it, this will get back the node info.
    void
    PeerListener.gotPort(Peer peer, int port, int rport)
    Called when a DHT port message is received.
    PeerCoordinator.gotRequest(Peer peer, int piece, int off, int len)
    Returns a byte array containing the requested piece or null of the piece is unknown.
    PeerListener.gotRequest(Peer peer, int piece, int off, int len)
    Called when the peer wants (part of) a piece from us.
    private static void
    ExtensionHandler.handleComment(Peer peer, PeerListener listener, byte[] bs, Log log)
    Handles an incoming comment request or response message.
    private static void
    ExtensionHandler.handleDHT(Peer peer, PeerListener listener, byte[] bs, Log log)
    Handles an incoming DHT port message.
    private static void
    ExtensionHandler.handleHandshake(Peer peer, PeerListener listener, byte[] bs, Log log)
    Handles an incoming extension handshake message.
    static void
    ExtensionHandler.handleMessage(Peer peer, PeerListener listener, int id, byte[] bs)
    Handles an incoming extension message from a peer.
    private static void
    ExtensionHandler.handleMetadata(Peer peer, PeerListener listener, byte[] bs, Log log)
    Handles an incoming metadata extension message (BEP 9).
    private static void
    ExtensionHandler.handlePEX(Peer peer, PeerListener listener, byte[] bs, Log log)
    Handles an incoming PEX message.
    boolean
    Piece.isRequestedBy(Peer peer)
    Checks if the given peer is currently requesting this piece.
    static void
    ExtensionHandler.locked_sendComments(Peer peer, int num, CommentSet comments)
    Sends comments to a peer.
    private void
    PeerCoordinator.markUnrequested(Peer peer, int piece)
    Clear the requested flag for a piece.
    boolean
    PeerCoordinator.needPiece(Peer peer, BitField havePieces)
    Called when we are downloading from the peer and may need to ask for a new piece.
    boolean
    PeerListener.needPiece(Peer peer, BitField bitfield)
    Called when we are downloading from the peer and may need to ask for a new piece.
    void
    CoordinatorListener.peerChange(PeerCoordinator coordinator, Peer peer)
    Called when the PeerCoordinator notices a change in the state of a peer.
    void
    Snark.peerChange(PeerCoordinator coordinator, Peer peer)
    CoordinatorListener no-op.
    (package private) void
    PeerCoordinator.recordSwarmPeer(Peer peer)
    Record a peer surfaced by any source (announce, PEX, DHT, inbound) as a distinct swarm member, keyed by destination hash.
    boolean
    Piece.removePeer(Peer peer)
    Removes a peer from those that have this piece.
    private void
    PeerCoordinator.removePeerFromPieces(Peer peer)
    Called when a peer is removed, to prevent it from being used in rarest-first calculations.
    void
    PeerCoordinator.savePartialPieces(Peer peer, List<Request> partials)
    Save partial pieces on peer disconnection and hopefully restart it later.
    void
    PeerListener.savePartialPieces(Peer peer, List<Request> pcs)
    Called when the peer has disconnected and the peer task may have a partially downloaded piece that the PeerCoordinator can save.
    static void
    ExtensionHandler.sendCommentReq(Peer peer, int num)
    Sends a comment request to a peer.
    (package private) void
    PeerCoordinator.sendCommentReq(Peer peer)
    Send a comment request message to the peer, if he supports it.
    static void
    ExtensionHandler.sendDHT(Peer peer, int qport, int rport)
    Sends DHT port numbers to a peer.
    (package private) void
    PeerCoordinator.sendDHT(Peer peer)
    Send a DHT message to the peer, if we both support DHT.
    static void
    ExtensionHandler.sendDontHave(Peer peer, int piece)
    Send a BEP 54 lt_donthave message to a peer that advertised support: the piece is no longer available.
    private static void
    ExtensionHandler.sendExtension(Peer peer, String type, byte[] payload)
    Send an extension message to a peer, looking up its message code for the given type in the handshake.
    private static void
    ExtensionHandler.sendMessage(Peer peer, int type, int piece)
    Sends a metadata request or reject message to a peer.
    (package private) void
    PeerCoordinator.sendPeers(Peer peer)
    Send a PEX message to the peer, if he supports PEX.
    static void
    ExtensionHandler.sendPEX(Peer peer, List<Peer> pList)
    Sends a PEX message with the given peer list.
    private static void
    ExtensionHandler.sendPiece(Peer peer, int piece, byte[] data, int totalSize)
    Sends a metadata chunk data message to a peer.
    private static void
    ExtensionHandler.sendRequest(Peer peer, int piece)
    Sends a metadata chunk request to a peer.
    void
    Piece.setRequested(Peer peer, boolean requested)
    Marks a peer as requesting or no longer requesting this piece.
    boolean
    BandwidthListener.shouldRequest(Peer peer, int size)
    Checks if we should request the given number of bytes from a peer.
    boolean
    BandwidthManager.shouldRequest(Peer peer, int size)
    Should we request this many bytes?
    boolean
    Peer.shouldRequest(Peer peer, int size)
    Should we request this many bytes? Only true for this peer, which is how a callback that was handed one peer is prevented from answering for another.
    boolean
    PeerCoordinator.shouldRequest(Peer peer, int size)
    Should we request this many bytes?
    private Piece
    PeerCoordinator.wantPiece(Peer peer, BitField havePieces, boolean record)
    Returns one of pieces in the given BitField that is still wanted or null if none of the given pieces are wanted.
    private Piece
    PeerCoordinator.wantPiece(Peer peer, BitField havePieces, boolean record, Set<Integer> allowed)
    Returns one of the claimed pieces in the given BitField that is still wanted or null if none of the given pieces are wanted.
    Method parameters in org.klomp.snark with type arguments of type Peer
    Modifier and Type
    Method
    Description
    private static Peer
    PeerCoordinator.peerIDInList(PeerID pid, Collection<Peer> peers)
    The peer with the given ID, or null.
    static void
    ExtensionHandler.sendPEX(Peer peer, List<Peer> pList)
    Sends a PEX message with the given peer list.
    private void
    TrackerClient.tryAddPeers(Collection<Peer> peers)
    Try to connect to the given peers, spreading the connection attempts over time.
    Constructors in org.klomp.snark with parameters of type Peer
    Modifier
    Constructor
    Description
    Create a handler for incoming messages from a peer.
    Creates a new outgoing connection handler.
    (package private)
    Create the peer state for the torrent.
  • Uses of Peer in org.klomp.snark.web

    Classes in org.klomp.snark.web that implement interfaces with type arguments of type Peer
    Modifier and Type
    Class
    Description
    private static class 
    Sort by completeness (seeds first), then by ID.
    Methods in org.klomp.snark.web with parameters of type Peer
    Modifier and Type
    Method
    Description
    private void
    I2PSnarkServlet.appendPeerRow(StringBuilder buf, Peer peer, Snark snark, MetaInfo meta, boolean noThinsp)
    Appends HTML for a single peer row to the given StringBuilder.
    (package private) static I2PSnarkServlet.PeerStatus
    I2PSnarkServlet.classifyPeerStatus(Peer peer)
    Determines the peer status (active/inactive with TX/RX flags).
    int
    I2PSnarkServlet.PeerComparator.compare(Peer l, Peer r)
     
    private String
    I2PSnarkServlet.getClientName(Peer peer)
    Returns a human-readable name of the client associated with the given Peer.
    private void
    I2PSnarkServlet.renderDownloadRate(StringBuilder buf, Peer peer, I2PSnarkServlet.PeerRowContext ctx, long needed)
    Renders the download rate cell.
    private void
    Renders the peer identity/client section.
    private float
    Renders the peer progress bar or seed indicator.
    private void
    I2PSnarkServlet.renderUploadRate(StringBuilder buf, Peer peer, I2PSnarkServlet.PeerRowContext ctx, float pct, boolean isValid)
    Renders the upload rate cell.