Goal
Rename the type alias NumberOfDownloadsBTreeMap to NumberOfDownloadsPerInfoHash so the name expresses the intent of the type ("downloads per info-hash") rather than its internal implementation (BTreeMap).
Background
The type alias is defined in packages/primitives/src/lib.rs:
pub type NumberOfDownloads = u32;
pub type NumberOfDownloadsBTreeMap = BTreeMap<InfoHash, NumberOfDownloads>;
It represents the number of completed downloads per info-hash and serves as the persistence boundary for torrent download counts — used by all three database drivers (SQLite, MySQL, PostgreSQL) when loading torrent metrics from the database.
The current name NumberOfDownloadsBTreeMap leaks the implementation detail (BTreeMap). If the underlying collection were ever changed (e.g., to a HashMap), the name would become misleading and need a follow-up rename.
The sibling type NumberOfDownloads is named after what it represents, not how it's stored (u32). The pair should follow the same convention.
A workspace-wide search found 19 source files and 4 documentation files referencing this alias, making this a low-risk but moderately broad rename.
Scope
In Scope
- Rename
NumberOfDownloadsBTreeMap to NumberOfDownloadsPerInfoHash in packages/primitives/src/lib.rs
- Update all references across the workspace (~19 source files + 4 doc files)
- Verify
linter all and the full test suite pass
Out of Scope
- Changing the underlying collection type (
BTreeMap → something else)
- Renaming other type aliases in the codebase
- Changing the
NumberOfDownloads alias (already well-named)
References
- Spec:
docs/issues/drafts/rename-number-of-downloads-btree-map-type-alias.md
- Definition:
packages/primitives/src/lib.rs (line 71)
Goal
Rename the type alias
NumberOfDownloadsBTreeMaptoNumberOfDownloadsPerInfoHashso the name expresses the intent of the type ("downloads per info-hash") rather than its internal implementation (BTreeMap).Background
The type alias is defined in
packages/primitives/src/lib.rs:It represents the number of completed downloads per info-hash and serves as the persistence boundary for torrent download counts — used by all three database drivers (SQLite, MySQL, PostgreSQL) when loading torrent metrics from the database.
The current name
NumberOfDownloadsBTreeMapleaks the implementation detail (BTreeMap). If the underlying collection were ever changed (e.g., to aHashMap), the name would become misleading and need a follow-up rename.The sibling type
NumberOfDownloadsis named after what it represents, not how it's stored (u32). The pair should follow the same convention.A workspace-wide search found 19 source files and 4 documentation files referencing this alias, making this a low-risk but moderately broad rename.
Scope
In Scope
NumberOfDownloadsBTreeMaptoNumberOfDownloadsPerInfoHashinpackages/primitives/src/lib.rslinter alland the full test suite passOut of Scope
BTreeMap→ something else)NumberOfDownloadsalias (already well-named)References
docs/issues/drafts/rename-number-of-downloads-btree-map-type-alias.mdpackages/primitives/src/lib.rs(line 71)