AddTorrentParams
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
infodictionary bytes.write_resume_dataembeds those bytes verbatim under theinfokey (entry["info"].preformatted()), andread_resume_datarecovers them from a presentinfodict. 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 deprecatedurl/resume_data) are not modelled.The v2 merkle-tree fields (merkleTrees, merkleTreeMask, verifiedLeafHashes) are carried verbatim and round-trip through the
treesresume key (each entry a{ "hashes", "verified", "mask" }dict, as inwrite_resume_data/read_resume_data). TheMerkleTreemachinery 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
Properties
Seconds spent in the started state.
Peers banned from this torrent.
When the download completed; 0 ⇒ unknown.
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).
Download rate cap in bytes/sec; -1 ⇒ unlimited.
Per-file download priorities (0..7); shorter than the file count ⇒ rest default.
Seconds spent finished.
torrent_flags_t mask; see TorrentFlags. Defaults to TorrentFlags.DEFAULT_FLAGS.
Pieces we already have.
v1 info-hash (SHA-1), when known even without full metadata.
v2 info-hash (SHA-256), when known.
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.
When payload was last downloaded; 0 ⇒ never/unknown.
When a complete copy was last seen in the swarm; 0 ⇒ unknown.
When payload was last uploaded; 0 ⇒ never/unknown.
Max peer connections; -1 ⇒ unlimited.
Max simultaneous uploads; -1 ⇒ unlimited.
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.
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.
Seeds in the swarm; -1 ⇒ unknown.
Number of completed downloads reported; -1 ⇒ unknown.
Non-seed peers in the swarm; -1 ⇒ unknown.
Per-piece download priorities (0..7). File priorities take precedence.
File index → new filename to apply before adding (renamed/relocated files).
Seconds spent seeding.
Storage allocation mode; true ⇒ allocate (full), false ⇒ sparse (default).
Parsed torrent metadata, when available (the immutable info-dict view).
Total bytes downloaded so far.
Total bytes uploaded so far.
Tracker announce URLs (flat list, aligned 1:1 with trackerTiers).
Tier index for each entry of trackers; empty ⇒ all tier 0.
Partially downloaded pieces: piece index → 16 KiB-block bitfield (set ⇒ have block).
Upload rate cap in bytes/sec; -1 ⇒ unlimited.
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.
In seed mode, pieces verified valid.