Repository navigation
refactor: move PeerNetwork onto the PeerTransport trait - #7925
Open
rob-stacks wants to merge 1 commit into
Open
rob-stacks wants to merge 1 commit into
rob-stacks wants to merge 1 commit into
Conversation
rob-stacks
requested review from
benjamin-stacks,
brice-stacks and
federico-stacks
December 1, 2026 12:15
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the PeerNetwork transport-abstraction refactor.
No open issues 🎉
What changed in this PR
Moves PeerNetwork onto the PeerTransport abstraction introduced in #7864, preparing for replaceable transports while retaining TCP as the default.
Changes:
- Delegates connection lifecycle, polling, and stream ownership to the transport.
- Adds a pre-bind
set_transport()hook and a stream-return reminder. - Adapts disconnect tests and documents the refactor.
| File | Description |
|---|---|
stackslib/src/net/transport/mod.rs |
Adds must_use guidance for borrowed streams. |
stackslib/src/net/tests/neighbors.rs |
Simulates disconnects through transport-owned streams. |
stackslib/src/net/p2p.rs |
Replaces direct TCP handling with transport delegation. |
changelog.d/p2p-transport-trait.changed |
Records the refactor and intended unchanged TCP behavior. |
Review effort: Balanced
federico-stacks
approved these changes
Dec 4, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Dec 4, 2026
This branch has not been deployed
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.
Description
Second step of making the p2p network's transport replaceable.
#7864 added the
PeerTransporttrait andTcpTransport; this PR makesPeerNetworkactually use them.Until now,
PeerNetworkowned every peer's TCP socket and called mio directly to bind, connect, accept and close. After this PR it only deals with connection IDs and byte streams, and everything socket-related lives inTcpTransport. The original TCP code is removed fromp2p.rs, so the diff is mostly deletions.The node's behavior doesn't change: it still uses plain TCP, with no consensus, wire-format or configuration changes. The only new hook is
PeerNetwork::set_transport(), which lets a caller pick another transport before binding; nothing calls it yet. The next PR uses it to add an in-memory transport for tests.