Skip to content

SI-21: Migrate from bittorrent-primitives to torrust-info-hash #1889

Description

@josecelano

Goal

Replace the bittorrent-primitives crate dependency with the new torrust-info-hash crate (v0.1.0) across the entire workspace. The InfoHash type originally came from bittorrent-primitives and has now been published as a standalone crate torrust-info-hash from the torrust/torrust-bittorrent monorepo (see torrust/torrust-bittorrent#87 / torrust/torrust-bittorrent#88).

Background

The bittorrent-primitives crate (v0.2.0) is a single-package repository whose sole public type is InfoHash. As part of the broader workspace overhaul (EPIC #1669), the InfoHash type has been migrated to the torrust/torrust-bittorrent workspace as torrust-info-hash v0.1.0 and published to crates.io.

This workspace (torrust/torrust-tracker) currently depends on bittorrent-primitives in 14 Cargo.toml files (13 packages + the root crate for dev-dependencies) — exclusively for the InfoHash type. Replacing it with torrust-info-hash reduces the dependency footprint and moves toward deprecating/archiving the torrust/bittorrent-primitives repository.

Note: the udp-protocol package (torrust-tracker-udp-tracker-protocol) defines its own local InfoHash struct (a newtype over [u8; 20]) and does NOT use bittorrent-primitives. It is not in scope for this migration.

Scope

In Scope

  • Replace bittorrent-primitives = "0.2.0" with torrust-info-hash = "=0.1.0" in all workspace Cargo.toml files that use it for InfoHash
  • Update all Rust source files: use bittorrent_primitives::info_hash::InfoHash -> use torrust_info_hash::InfoHash
  • Update doc comments that reference the old import path (bittorrent_primitives::info_hash::InfoHash)
  • Remove bittorrent-primitives from root Cargo.toml dev-dependencies if no longer needed
  • Run cargo machete to verify no unused dependencies remain
  • Run linter all and full test suite to validate
  • Update AGENTS.md if the package table requires changes
  • Update project-words.txt with any new technical terms

Out of Scope

  • The udp-protocol package's local InfoHash struct — it is unrelated to bittorrent-primitives (see background)
  • Migrating any other types — torrust-info-hash only contains InfoHash
  • Publishing new crates to crates.io
  • Archiving the torrust/bittorrent-primitives repository

Implementation Plan

ID Status Task Notes / Expected Output
T1 TODO Add torrust-info-hash to root workspace Cargo.toml dependencies section Add torrust-info-hash version pin for workspace-wide use
T2 TODO Replace dependency + imports in packages/http-tracker-core Cargo.toml + all .rs imports and doc comments
T3 TODO Replace dependency + imports in packages/http-protocol Cargo.toml + all .rs imports and doc comments
T4 TODO Replace dependency + imports in packages/primitives Cargo.toml + all .rs imports and doc comments
T5 TODO Replace dependency + imports in packages/tracker-core Cargo.toml + all .rs imports and doc comments
T6 TODO Replace dependency + imports in packages/tracker-client Cargo.toml + all .rs imports and doc comments
T7 TODO Replace dependency + imports in packages/udp-tracker-core Cargo.toml + all .rs imports and doc comments
T8 TODO Replace dependency + imports in packages/udp-server Cargo.toml + all .rs imports and doc comments
T9 TODO Replace dependency + imports in packages/axum-rest-api-server Cargo.toml + all .rs imports and doc comments
T10 TODO Replace dependency + imports in packages/axum-http-server Cargo.toml + all .rs imports and doc comments
T11 TODO Replace dependency + imports in packages/swarm-coordination-registry Cargo.toml + all .rs imports and doc comments
T12 TODO Replace dependency + imports in packages/torrent-repository-benchmarking Cargo.toml + all .rs imports and doc comments
T13 TODO Replace dependency + imports in packages/persistence-benchmark Cargo.toml + all .rs imports and doc comments
T14 TODO Replace dependency + imports in console/tracker-client Cargo.toml + all .rs imports and doc comments
T15 TODO Replace root dev-dependency + update tests/ imports Root Cargo.toml + tests/servers/ files
T16 TODO Remove bittorrent-primitives from all Cargo.toml files After confirming no remaining references
T17 TODO Run cargo check --workspace Verify compilation
T18 TODO Run cargo machete Verify no unused dependencies
T19 TODO Run linter all Verify linting passes
T20 TODO Run cargo test --workspace Verify tests pass
T21 TODO Update project-words.txt Add any needed terms
T22 TODO Update AGENTS.md if needed If workspace package table changes

Acceptance Criteria

  • AC1: All Cargo.toml files use torrust-info-hash = "=0.1.0" instead of bittorrent-primitives = "0.2.0" for InfoHash
  • AC2: All Rust source imports use use torrust_info_hash::InfoHash instead of use bittorrent_primitives::info_hash::InfoHash
  • AC3: No remaining references to bittorrent-primitives or bittorrent_primitives except the comment in udp-protocol/src/common.rs (which is out of scope)
  • AC4: cargo check --workspace exits with code 0
  • AC5: cargo machete exits with code 0
  • AC6: linter all exits with code 0
  • AC7: cargo test --workspace passes
  • AC8: project-words.txt is up to date
  • AC9: Documentation is updated when behavior/workflow changes
  • AC10: Manual verification scenarios are executed and documented (status + evidence)
  • AC11: Acceptance criteria are re-reviewed after implementation and reflect actual behavior

Metadata

Metadata

Assignees

Labels

rustPull requests that update Rust codetask

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions