AddTorrentParams

data class AddTorrentParams(val ti: TorrentInfo? = null, val infoSection: ByteArray? = null, val infoHashV1: Sha1Hash? = null, val infoHashV2: Sha256Hash? = null, val name: String = "", val savePath: String = "", val trackers: List<String> = emptyList(), val trackerTiers: List<Int> = emptyList(), val dhtNodes: List<Pair<String, Int>> = emptyList(), val urlSeeds: List<String> = emptyList(), val httpSeeds: List<String> = emptyList(), val trackerId: String = "", val peers: List<Endpoint> = emptyList(), val bannedPeers: List<Endpoint> = emptyList(), val filePriorities: List<Int> = emptyList(), val piecePriorities: List<Int> = emptyList(), val havePieces: Bitfield = Bitfield(), val verifiedPieces: Bitfield = Bitfield(), val unfinishedPieces: Map<Int, Bitfield> = emptyMap(), val renamedFiles: Map<Int, String> = emptyMap(), val merkleTrees: List<List<Digest32>> = emptyList(), val merkleTreeMask: List<List<Boolean>> = emptyList(), val verifiedLeafHashes: List<List<Boolean>> = emptyList(), val flags: Long = TorrentFlags.DEFAULT_FLAGS, val storageModeAllocate: Boolean = false, val maxUploads: Int = -1, val maxConnections: Int = -1, val uploadLimit: Int = -1, val downloadLimit: Int = -1, val totalUploaded: Long = 0, val totalDownloaded: Long = 0, val activeTime: Int = 0, val finishedTime: Int = 0, val seedingTime: Int = 0, val addedTime: Long = 0, val completedTime: Long = 0, val lastSeenComplete: Long = 0, val lastDownload: Long = 0, val lastUpload: Long = 0, val numComplete: Int = -1, val numIncomplete: Int = -1, val numDownloaded: Int = -1, val completeSent: Boolean = false)

The pure-Kotlin port of libtorrent's add_torrent_params (include/libtorrent/add_torrent_params.hpp): all the information needed to add a torrent to a session, and the in-memory shape that fast-resume data round-trips through.

This is the full config object, the counterpart of the C++ struct. It is the type ResumeData.write and ResumeData.read serialise. (KiteTorrent already has a smaller, load-focused AddTorrentParams in io.github.yuroyami.kitetorrent.torrent produced by LoadTorrent; this resume variant lives in its own package to keep both faithful to the names libtorrent uses without clashing.)

Fidelity notes / deliberate omissions:

  • ti is the parsed metadata when known; infoSection holds the raw bencoded info dictionary bytes. write_resume_data embeds those bytes verbatim under the info key (entry["info"].preformatted()), and read_resume_data recovers them from a present info dict. infoSection is therefore what crosses the serialisation boundary, while ti is the convenient decoded view.

  • Session-runtime-only and extension fields from the C++ struct (userdata, extensions, the deprecated url/resume_data) are not modelled.

  • The v2 merkle-tree fields (merkleTrees, merkleTreeMask, verifiedLeafHashes) are carried verbatim and round-trip through the trees resume key (each entry a { "hashes", "verified", "mask" } dict, as in write_resume_data/read_resume_data). The MerkleTree machinery still owns the actual hash reconstruction; this struct only preserves the bytes losslessly across a save/load cycle.

Every list/map defaults to empty and every scalar to libtorrent's documented default (e.g. the rate/connection limits to -1 = unlimited, the scrape counts to -1 = unknown, flags to TorrentFlags.DEFAULT_FLAGS).

Constructors

Link copied to clipboard
constructor(ti: TorrentInfo? = null, infoSection: ByteArray? = null, infoHashV1: Sha1Hash? = null, infoHashV2: Sha256Hash? = null, name: String = "", savePath: String = "", trackers: List<String> = emptyList(), trackerTiers: List<Int> = emptyList(), dhtNodes: List<Pair<String, Int>> = emptyList(), urlSeeds: List<String> = emptyList(), httpSeeds: List<String> = emptyList(), trackerId: String = "", peers: List<Endpoint> = emptyList(), bannedPeers: List<Endpoint> = emptyList(), filePriorities: List<Int> = emptyList(), piecePriorities: List<Int> = emptyList(), havePieces: Bitfield = Bitfield(), verifiedPieces: Bitfield = Bitfield(), unfinishedPieces: Map<Int, Bitfield> = emptyMap(), renamedFiles: Map<Int, String> = emptyMap(), merkleTrees: List<List<Digest32>> = emptyList(), merkleTreeMask: List<List<Boolean>> = emptyList(), verifiedLeafHashes: List<List<Boolean>> = emptyList(), flags: Long = TorrentFlags.DEFAULT_FLAGS, storageModeAllocate: Boolean = false, maxUploads: Int = -1, maxConnections: Int = -1, uploadLimit: Int = -1, downloadLimit: Int = -1, totalUploaded: Long = 0, totalDownloaded: Long = 0, activeTime: Int = 0, finishedTime: Int = 0, seedingTime: Int = 0, addedTime: Long = 0, completedTime: Long = 0, lastSeenComplete: Long = 0, lastDownload: Long = 0, lastUpload: Long = 0, numComplete: Int = -1, numIncomplete: Int = -1, numDownloaded: Int = -1, completeSent: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Seconds spent in the started state.

Link copied to clipboard

When the torrent was first added; 0 ⇒ set on add.

Link copied to clipboard

Peers banned from this torrent.

Link copied to clipboard

When the download completed; 0 ⇒ unknown.

Link copied to clipboard

Whether a completed tracker announce has already been sent for this torrent (libtorrent's per-endpoint complete_sent / torrent::m_complete_sent). Persisted so a re-added finished torrent does not re-announce event=completed. Stored under the complete_sent resume key (an additive key libtorrent ignores when absent).

Link copied to clipboard

DHT bootstrap nodes as host/port pairs.

Link copied to clipboard

Download rate cap in bytes/sec; -1 ⇒ unlimited.

Link copied to clipboard

Per-file download priorities (0..7); shorter than the file count ⇒ rest default.

Link copied to clipboard

Seconds spent finished.

Link copied to clipboard
val flags: Long

torrent_flags_t mask; see TorrentFlags. Defaults to TorrentFlags.DEFAULT_FLAGS.

Link copied to clipboard

Pieces we already have.

Link copied to clipboard

BEP 17 HTTP seeds (httpseeds).

Link copied to clipboard

v1 info-hash (SHA-1), when known even without full metadata.

Link copied to clipboard

v2 info-hash (SHA-256), when known.

Link copied to clipboard

Raw bencoded bytes of the info dictionary, when available. This is the preimage of the info-hash and what gets embedded in / read from resume data.

Link copied to clipboard

When payload was last downloaded; 0 ⇒ never/unknown.

Link copied to clipboard

When a complete copy was last seen in the swarm; 0 ⇒ unknown.

Link copied to clipboard

When payload was last uploaded; 0 ⇒ never/unknown.

Link copied to clipboard

Max peer connections; -1 ⇒ unlimited.

Link copied to clipboard

Max simultaneous uploads; -1 ⇒ unlimited.

Link copied to clipboard

Per-file bitmask marking which positions in the full merkle tree the corresponding entry of merkleTrees actually fills, the port of merkle_tree_mask. An empty inner list (for a present merkleTrees entry) means the tree is dense (all nodes present). Round-trips through the trees/mask key.

Link copied to clipboard

Per-file merkle-tree node hashes (SHA-256), the port of add_torrent_params::merkle_trees (aux::vector<std::vector<sha256_hash>>). Outer index = file index; inner list = the (sparse or full) tree nodes for that file. Empty for v1-only torrents. Round-trips through the trees/hashes key.

Link copied to clipboard

Display name used while the torrent has no metadata.

Link copied to clipboard

Seeds in the swarm; -1 ⇒ unknown.

Link copied to clipboard

Number of completed downloads reported; -1 ⇒ unknown.

Link copied to clipboard

Non-seed peers in the swarm; -1 ⇒ unknown.

Link copied to clipboard

Peers to try connecting to.

Link copied to clipboard

Per-piece download priorities (0..7). File priorities take precedence.

Link copied to clipboard

File index → new filename to apply before adding (renamed/relocated files).

Link copied to clipboard

Where the torrent's files are / will be stored.

Link copied to clipboard

Seconds spent seeding.

Link copied to clipboard

Storage allocation mode; true ⇒ allocate (full), false ⇒ sparse (default).

Link copied to clipboard

Parsed torrent metadata, when available (the immutable info-dict view).

Link copied to clipboard

Total bytes downloaded so far.

Link copied to clipboard

Total bytes uploaded so far.

Link copied to clipboard

Default tracker id used when announcing (empty ⇒ none).

Link copied to clipboard

Tracker announce URLs (flat list, aligned 1:1 with trackerTiers).

Link copied to clipboard

Tier index for each entry of trackers; empty ⇒ all tier 0.

Link copied to clipboard

Partially downloaded pieces: piece index → 16 KiB-block bitfield (set ⇒ have block).

Link copied to clipboard

Upload rate cap in bytes/sec; -1 ⇒ unlimited.

Link copied to clipboard

BEP 19 "get right" web seeds (url-list).

Link copied to clipboard

Per-file bitmask of which leaf hashes have been verified against the root, the port of verified_leaf_hashes. Empty inner list with a non-empty merkleTrees entry implies all hashes are verified. Round-trips through the trees/verified key.

Link copied to clipboard

In seed mode, pieces verified valid.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
fun hasFlag(flag: Long): Boolean

True if this flag (a single-bit mask from TorrentFlags) is set.

Link copied to clipboard
open override fun hashCode(): Int