shim: inspection getters — file table + piece availability (ABI v5)#19
Merged
Conversation
Batch 2 of surfacing more of libtorrent: let script see INSIDE a torrent. Until now there was no way to enumerate a torrent's files at all. New btx_* ABI (v4 -> v5, append-only): - btx_file_list - the torrent's files as a count-prefixed list of KV records, one per file: path (relative), size, bytes downloaded, and download priority. One FFI round-trip returns the whole file table (perf playbook). Empty until metadata arrives, so it doubles as a "do we have metadata yet" probe. Pulls per-file progress + priorities in two bulk engine calls, mirrors the peer-list framing exactly. - btx_piece_availability - one byte per piece (peers advertising it, clamped to 255) as a raw view, like btx_piece_bitfield; pair the two for a full piece map. Record schema: four append-only file-entry fields (F_FILE_PATH/SIZE/PROGRESS/ PRIORITY = 120..123), mirrored as kField* + keys path/size/progress/priority in _fieldKey. LCB: kABIVersion -> 5; two foreign decls + btFileList (List of Arrays) / btPieceAvailability (Data) wrappers. 56 -> 58 public handlers. Built + run under gcc ASan/UBSan against real libtorrent: 430 checks, 0 failures, clean -Wall -Wextra. Static gates green (check-livecodescript 7/7; record-registry 95 in sync; golden OK; ABI 5<->5). README + api-reference (entries + file-entry key table) updated. CI rebuilds the 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 2 of surfacing more of libtorrent — let script see inside a torrent. Until now there was no way to enumerate a torrent's files at all; this batch fixes the biggest inspection gap.
New ABI (v4 → v5, append-only)
btx_*bt*file_listbtFileListListofArrayspath,size,progress(bytes downloaded),priority(0..7)piece_availabilitybtPieceAvailabilityData56 → 58 public handlers.
btFileListreturns the whole file table in one FFI round-trip (per the single-thread perf playbook), pulling per-file progress + priorities in two bulk engine calls and reusing the exact peer-list framing. It's empty until metadata arrives, so it doubles as a "do we have metadata yet?" probe.btPieceAvailabilitypairs withbtPieceBitfield(which pieces you have) for a full piece/rarity map.Schema
Four append-only file-entry fields —
F_FILE_PATH/SIZE/PROGRESS/PRIORITY(120–123) — mirrored askField*and as keyspath/size/progress/priorityin_fieldKey. Registry stays in lock-step: 95 constants in sync (was 91).Verification
-Wall -Wextra. New getters assert empty/0on a bogus handle.check-livecodescript7/7;check-record-registry95 in sync; golden vectors OK;BTX_ABI_VERSION↔kABIVersionboth 5.Remaining roadmap
🤖 Generated with Claude Code
https://claude.ai/code/session_01371AXB4CUUke7enHHS8okc
Generated by Claude Code