shim: extended torrent control — flags, caps, queue, scrape, move (ABI v4)#18
Merged
Merged
Conversation
…I v4) Batch 1 of surfacing more of libtorrent's protocol: nine new torrent_handle actions, all fire-and-forget, several of whose result alerts were already wired (A_SCRAPE_REPLY, A_STORAGE_MOVED) but had no trigger until now. New btx_* ABI (v3 -> v4, append-only): - btx_set_torrent_flags / btx_unset_torrent_flags - the full torrent_flags_t set (sequential_download, auto_managed, share/upload/super-seed modes, apply_ip_filter, stop_when_ready, ...), carried as a 64-bit decimal string. - btx_set_max_connections / btx_set_max_uploads - per-torrent caps. - btx_torrent_clear_error - clear a torrent's error so it can resume. - btx_scrape_tracker - request seed/leecher counts (-> scrapeReply). - btx_move_storage - relocate downloaded files (-> storageMoved / fileError). - btx_queue_position (getter; -1 == not queued, the one int-getter using -1 not 0 since 0 is a real position) + btx_queue_move (up/down/top/bottom). LCB layer: kABIVersion -> 4; nine foreign decls + public bt* wrappers; the kFlag* bit-value constants mirroring libtorrent/torrent_flags.hpp; and named convenience wrappers (btSetSequentialDownload / AutoManaged / SuperSeeding / ShareMode / UploadMode) over the generic flags pair. 39 -> 56 public handlers. Smoke test: every new entry point is a harmless error on a bogus handle, plus queue-op range validation. Built + run under gcc ASan/UBSan against real libtorrent: 416 checks, 0 failures, clean -Wall -Wextra. Static gates green (check-livecodescript 7/7; record-registry 91 in sync; golden OK). README + api-reference updated. CI rebuilds the committed binaries on merge. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01371AXB4CUUke7enHHS8okc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch 1 of surfacing more of libtorrent's protocol. The audit found the event surface already rich, but
torrent_handleactions had real gaps — and tellingly, several were missing even though their result alerts were already wired (A_SCRAPE_REPLY,A_STORAGE_MOVED). This batch fills the control/storage side.New ABI (v3 → v4, append-only)
btx_*bt*set_torrent_flags/unset_torrent_flagsbtSetTorrentFlags/btUnsetTorrentFlagstorrent_flags_tset, carried as a 64-bit decimal stringbtSetSequentialDownload·btSetAutoManaged·btSetSuperSeeding·btSetShareMode·btSetUploadModeset_max_connections/set_max_uploadsbtSetMaxConnections/btSetMaxUploadstorrent_clear_errorbtClearTorrentErrorscrape_trackerbtScrapeTrackerscrapeReply)move_storagebtMoveStoragestorageMoved/fileError)queue_position/queue_movebtQueuePosition·btQueueUp/Down/Top/Bottom39 → 56 public handlers. The LCB layer also gains the
kFlag*bit-value constants (mirroringlibtorrent/torrent_flags.hpp) so script can combine flags readably.Design notes
set(flags, mask)writes only the masked bits, so it's a clean read-modify-write.btQueuePositionreturns-1, not0, for "not queued" — the one int-getter that does, because0is a real queue position. Documented inbtx_abi.hand the API reference.torrent_only, wrap in theBTX_GUARD_*firewall, no-op-with-error on a stale handle.Verification
-Wall -Wextra. New entry points each assert a harmless error on a bogus handle, plus queue-op range validation.check-livecodescript7/7;check-record-registry91 in sync (no record-schema change this batch); golden vectors OK;BTX_ABI_VERSION↔kABIVersionboth 4.src/codebinaries on merge (they're ABI v3 until then — same refresh flow as the BEP44 batch).Next batches (roadmap)
🤖 Generated with Claude Code
https://claude.ai/code/session_01371AXB4CUUke7enHHS8okc
Generated by Claude Code