Skip to content

refactor(udp-protocol): remove PeerId/PeerClient re-exports#1917

Merged
josecelano merged 3 commits into
torrust:developfrom
josecelano:1907-remove-udp-protocol-peer-id-re-export
Jun 17, 2026
Merged

refactor(udp-protocol): remove PeerId/PeerClient re-exports#1917
josecelano merged 3 commits into
torrust:developfrom
josecelano:1907-remove-udp-protocol-peer-id-re-export

Conversation

@josecelano

Copy link
Copy Markdown
Member

Closes #1907

The `torrust-tracker-udp-tracker-protocol` crate no longer re-exports
`PeerId` and `PeerClient`. All consumers now import directly from
`torrust-peer-id`.

This removes the #1 thin dependency identified in the workspace coupling
report (2026-06-10): `axum-http-server` no longer depends on
`udp-protocol` entirely — the dependency was removed from
`packages/axum-http-server/Cargo.toml`.

Also fixes `console/tracker-client` which was an additional consumer
beyond the original 4 listed in the issue scope.

Closes torrust#1907.
Copilot AI review requested due to automatic review settings June 17, 2026 10:58
@josecelano josecelano self-assigned this Jun 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets issue #1907 by decoupling workspace crates from torrust-tracker-udp-tracker-protocol’s PeerId/PeerClient surface area, updating consumers to import these types directly from torrust-peer-id.

Changes:

  • Updated workspace consumers (servers/clients/tests/console client) to import PeerId/PeerClient from torrust_peer_id.
  • Added torrust-peer-id dependencies where needed and removed the now-unnecessary udp-protocol dependency from axum-http-server.
  • Adjusted udp-protocol exports and updated the issue spec verification checklist.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/udp-server/src/statistics/event/handler/error.rs Switches PeerClient import to torrust_peer_id.
packages/udp-server/Cargo.toml Adds torrust-peer-id dependency.
packages/udp-protocol/src/lib.rs Removes direct crate-root PeerId/PeerClient re-export line.
packages/udp-protocol/src/common.rs Changes PeerId/PeerClient exposure point (currently still re-exported publicly).
packages/tracker-client/src/peer_id.rs Switches PeerId import to torrust_peer_id.
packages/tracker-client/src/http/client/requests/announce.rs Switches PeerId import to torrust_peer_id.
packages/tracker-client/Cargo.toml Adds torrust-peer-id dependency.
packages/axum-http-server/tests/server/v1/contract.rs Updates test code to use torrust_peer_id::PeerId.
packages/axum-http-server/tests/server/requests/announce.rs Updates request builder to use torrust_peer_id::PeerId.
packages/axum-http-server/Cargo.toml Removes udp-protocol dependency and adds torrust-peer-id.
docs/issues/open/1907-1669-si-26-remove-udp-protocol-peer-id-re-export.md Marks verification items as completed (needs alignment with actual udp-protocol exports).
console/tracker-client/src/console/clients/unified/http.rs Switches PeerId import to torrust_peer_id.
console/tracker-client/src/console/clients/http/app.rs Switches PeerId import to torrust_peer_id.
console/tracker-client/Cargo.toml Adds torrust-peer-id dependency.
Cargo.lock Updates lockfile for the new dependency edges.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/udp-protocol/src/common.rs Outdated
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.10%. Comparing base (7c7e050) to head (98d8979).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1917   +/-   ##
========================================
  Coverage    79.09%   79.10%           
========================================
  Files          326      326           
  Lines        22806    22806           
  Branches     22806    22806           
========================================
+ Hits         18038    18040    +2     
+ Misses        4505     4504    -1     
+ Partials       263      262    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The `pub use torrust_peer_id::{PeerClient, PeerId}` in `common.rs` was
still publicly re-exporting these types, which meant the crate's public
API was still coupled to `torrust-peer-id` despite the lib.rs re-exports
being removed.

Change summary:
- Made the re-exports in `common.rs` `pub(crate)` so they're only
  available internally, not in crate's public API
- Fixed all remaining consumers that imported `PeerId` from
  `udp-protocol` to import from `torrust_peer_id` instead

Consumers fixed:
- `packages/udp-server/src/handlers/announce.rs` (5 occurrences)
- `packages/udp-server/src/handlers/scrape.rs`
- `packages/udp-server/tests/server/contract.rs`
- `console/tracker-client/src/console/clients/udp/checker.rs`
- Updated doc link in `packages/udp-server/src/lib.rs`

Refs torrust#1907.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated no new comments.

@josecelano josecelano left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix commit 72bac14 addresses both Copilot suggestions. The re-export in common.rs is now pub(crate) (not pub), so it is no longer part of the crate's public API. All remaining consumers that imported PeerId from torrust_tracker_udp_tracker_protocol have been updated to import from torrust_peer_id instead. I've also replied to each suggestion thread with details.

The AquaticPeerId alias was a legacy from when the code was forked from aquatic_udp_protocol. Now that we use our own torrust_peer_id::PeerId, the alias is unnecessary.
@josecelano

Copy link
Copy Markdown
Member Author

ACK 98d8979

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 20 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

packages/udp-server/src/lib.rs:336

  • The AnnounceRequest field table has incorrect type/link entries: bytes_uploaded is labeled as TransactionId even though it links to NumberOfBytes, and ip_address links to ConnectionId and shows None even though AnnounceRequest.ip_address is an Ipv4AddrBytes (see udp-protocol AnnounceRequest). This can mislead readers of the UDP server docs.
//! `peer_id`          | [`PeerId`](torrust_peer_id::PeerId)                                                | `[45,113,66,52,52,49,48,45,41,83,100,126,100,101,52,120,77,112,54,68]`
//! `bytes_downloaded` | [`NumberOfBytes`](torrust_tracker_udp_tracker_protocol::common::NumberOfBytes)  | `0`
//! `bytes_uploaded`   | [`TransactionId`](torrust_tracker_udp_tracker_protocol::common::NumberOfBytes)  | `0`
//! `event`            | [`AnnounceEvent`](torrust_tracker_udp_tracker_protocol::AnnounceEvent) | `Started`
//! `ip_address`       | [`Ipv4Addr`](torrust_tracker_udp_tracker_protocol::common::ConnectionId)        | `None`

@josecelano josecelano merged commit bfe1544 into torrust:develop Jun 17, 2026
17 checks passed
@josecelano josecelano deleted the 1907-remove-udp-protocol-peer-id-re-export branch June 17, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SI-26: Remove udp-protocol re-export of PeerId/PeerClient (EPIC #1669)

2 participants