![JAR search and dependency download from the Maven repository](/logo.png)
bt.torrent.data.DataWorker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bt-core Show documentation
Show all versions of bt-core Show documentation
BitTorrent Client Library (Core)
package bt.torrent.data;
import bt.net.Peer;
import java.util.concurrent.CompletableFuture;
/**
* Data worker is responsible for processing blocks and block requests, received from peers.
*
* @since 1.0
*/
public interface DataWorker {
/**
* Add a read block request.
*
* @param peer Requestor
* @param pieceIndex Index of the requested piece (0-based)
* @param offset Offset in piece to start reading from (0-based)
* @param length Amount of bytes to read
* @return Future; rejected requests are returned immediately (see {@link BlockRead#isRejected()})
* @since 1.0
*/
CompletableFuture addBlockRequest(Peer peer, int pieceIndex, int offset, int length);
/**
* Add a write block request.
*
* @param peer Peer, that the data has been received from
* @param pieceIndex Index of the piece to write to (0-based)
* @param offset Offset in piece to start writing to (0-based)
* @param block Data
* @return Future; rejected requests are returned immediately (see {@link BlockWrite#isRejected()})
* @since 1.0
*/
CompletableFuture addBlock(Peer peer, int pieceIndex, int offset, byte[] block);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy