forked from cometbft/cometbft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(p2p)!: Extract TCP transport (cometbft#4148)
Closes cometbft#4301 This PR refactors the peer-to-peer (p2p) module by extracting the TCP transport into its own component, laying groundwork for potential QUIC transport integration. It introduces a breaking change to the Go API, particularly in the handling of peer connections and transport interfaces. **Important: no logic has been changed; just moving stuff and updating interfaces.** # Changes ## Public API * Updated `Transport` interface ```go // Transport emits and connects to Peers. The implementation of Peer is left to // the transport. Each transport is also responsible to filter establishing // peers specific to its domain. type Transport interface { // NetAddr returns the network address of the local node. NetAddr() na.Addr // Accept waits for and returns the next connection to the local node. Accept() (net.Conn, *na.Addr, error) // Dial dials the given address and returns a connection. Dial(addr na.Addr) (net.Conn, error) // Cleanup any resources associated with the given connection. // // Must be run when the peer is dropped for any reason. Cleanup(conn net.Conn) error } ``` ## New Go packages (extracted from `p2p`) * `netaddress` - network address * `nodeinfo` - node's info * `nodekey` - ID of the node * `transport/tcp` - TCP transport ## Internalized Go packages * `fuzz` - fuzzing connection #go-api-breaking --------- Co-authored-by: Andy Nogueira <me@andynogueira.dev>
- Loading branch information
Showing
98 changed files
with
2,718 additions
and
2,515 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
.changelog/unreleased/breaking-changes/4301-p2p-extract-tcp-transport.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- `[p2p]` Extracted TCP transport into its own package - `transport/tcp` | ||
* Updated `Transport` interface; | ||
* Moved `NetAddress`, `NodeInfo` and `NodeKey` into separate packages - | ||
`netaddress`, `nodeinfo`, `nodekey` accordingly; | ||
* Internalized `fuzz` package. | ||
[\#4301](https://github.com/cometbft/cometbft/issues/4301) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.