Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fa8151e
Fix `cargo-semver-checks` hickup
thomaseizinger Dec 8, 2022
b805939
Bump version in manifest and update changelog
thomaseizinger Dec 8, 2022
6995ff0
Rename public API symbols
thomaseizinger Dec 8, 2022
9f70789
Actually make it backwards-compatible
thomaseizinger Dec 8, 2022
4335ce1
Don't export more symbols than necessary
thomaseizinger Dec 9, 2022
9383624
Rename type back
thomaseizinger Dec 11, 2022
606047e
Merge branch 'master' into fix-semver-check-hickup
thomaseizinger Dec 11, 2022
406f62d
Update protocols/dcutr/CHANGELOG.md
thomaseizinger Dec 11, 2022
012ad58
Undo bump in `misc/metrics`
thomaseizinger Dec 11, 2022
21fb9b4
Undo bump and changelog entry in root lib
thomaseizinger Dec 11, 2022
5c1ec73
Make change more minimal
thomaseizinger Dec 11, 2022
0da964d
Merge branch 'fix-semver-check-hickup' of github.com:libp2p/rust-libp…
thomaseizinger Dec 11, 2022
c22a23e
Merge branch 'fix-semver-check-hickup' into dcutr-rename-public-api
thomaseizinger Dec 12, 2022
e7e4569
Add changelog entry
thomaseizinger Dec 12, 2022
d7e551c
Bump version in manifest
thomaseizinger Dec 12, 2022
4743994
Add TODO for future us
thomaseizinger Dec 12, 2022
96bf16c
Reference correct version in deprecation notice
thomaseizinger Dec 12, 2022
9ae2ce4
Merge branch 'master' into dcutr-rename-public-api
thomaseizinger Dec 14, 2022
536b295
Update deprecation version
thomaseizinger Dec 14, 2022
c0dc0ea
Add missing list marker in changelog
thomaseizinger Dec 14, 2022
c217b4b
Undo bad version bump from merge
thomaseizinger Dec 14, 2022
1ecc293
Merge branch 'master' into dcutr-rename-public-api
jxs Dec 19, 2022
ecd7bcc
Merge branch 'master' into dcutr-rename-public-api
jxs Dec 19, 2022
fc95f24
Merge branch 'master' into dcutr-rename-public-api
thomaseizinger Dec 19, 2022
6e163f6
Merge branch 'master' into dcutr-rename-public-api
mergify[bot] Dec 20, 2022
3b023a2
Merge branch 'master' into dcutr-rename-public-api
mergify[bot] Dec 20, 2022
0e0e803
Merge branch 'master' into dcutr-rename-public-api
mergify[bot] Dec 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions misc/metrics/src/dcutr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,30 @@ enum EventType {
DirectConnectionUpgradeFailed,
}

impl From<&libp2p_dcutr::behaviour::Event> for EventType {
fn from(event: &libp2p_dcutr::behaviour::Event) -> Self {
impl From<&libp2p_dcutr::Event> for EventType {
fn from(event: &libp2p_dcutr::Event) -> Self {
match event {
libp2p_dcutr::behaviour::Event::InitiatedDirectConnectionUpgrade {
libp2p_dcutr::Event::InitiatedDirectConnectionUpgrade {
remote_peer_id: _,
local_relayed_addr: _,
} => EventType::InitiateDirectConnectionUpgrade,
libp2p_dcutr::behaviour::Event::RemoteInitiatedDirectConnectionUpgrade {
libp2p_dcutr::Event::RemoteInitiatedDirectConnectionUpgrade {
remote_peer_id: _,
remote_relayed_addr: _,
} => EventType::RemoteInitiatedDirectConnectionUpgrade,
libp2p_dcutr::behaviour::Event::DirectConnectionUpgradeSucceeded {
remote_peer_id: _,
} => EventType::DirectConnectionUpgradeSucceeded,
libp2p_dcutr::behaviour::Event::DirectConnectionUpgradeFailed {
libp2p_dcutr::Event::DirectConnectionUpgradeSucceeded { remote_peer_id: _ } => {
EventType::DirectConnectionUpgradeSucceeded
}
libp2p_dcutr::Event::DirectConnectionUpgradeFailed {
remote_peer_id: _,
error: _,
} => EventType::DirectConnectionUpgradeFailed,
}
}
}

impl super::Recorder<libp2p_dcutr::behaviour::Event> for Metrics {
fn record(&self, event: &libp2p_dcutr::behaviour::Event) {
impl super::Recorder<libp2p_dcutr::Event> for Metrics {
fn record(&self, event: &libp2p_dcutr::Event) {
self.events
.get_or_create(&EventLabels {
event: event.into(),
Expand Down
4 changes: 2 additions & 2 deletions misc/metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ pub trait Recorder<Event> {
}

#[cfg(feature = "dcutr")]
impl Recorder<libp2p_dcutr::behaviour::Event> for Metrics {
fn record(&self, event: &libp2p_dcutr::behaviour::Event) {
impl Recorder<libp2p_dcutr::Event> for Metrics {
fn record(&self, event: &libp2p_dcutr::Event) {
self.dcutr.record(event)
}
}
Expand Down
4 changes: 4 additions & 0 deletions protocols/dcutr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

- Require the node's local `PeerId` to be passed into the constructor of `libp2p_dcutr::Behaviour`. See [PR 3153].

- Rename types in public API to follow naming conventions defined in [issue 2217]. See [PR 3214].

[PR 3213]: https://github.com/libp2p/rust-libp2p/pull/3213
[PR 3153]: https://github.com/libp2p/rust-libp2p/pull/3153
[issue 2217]: https://github.com/libp2p/rust-libp2p/issues/2217
[PR 3214]: https://github.com/libp2p/rust-libp2p/pull/3214

# 0.8.0

Expand Down
10 changes: 5 additions & 5 deletions protocols/dcutr/examples/dcutr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn main() -> Result<(), Box<dyn Error>> {
relay_client: Client,
ping: ping::Behaviour,
identify: identify::Behaviour,
dcutr: dcutr::behaviour::Behaviour,
dcutr: dcutr::Behaviour,
}

#[derive(Debug)]
Expand All @@ -123,7 +123,7 @@ fn main() -> Result<(), Box<dyn Error>> {
Ping(ping::Event),
Identify(identify::Event),
Relay(client::Event),
Dcutr(dcutr::behaviour::Event),
Dcutr(dcutr::Event),
}

impl From<ping::Event> for Event {
Expand All @@ -144,8 +144,8 @@ fn main() -> Result<(), Box<dyn Error>> {
}
}

impl From<dcutr::behaviour::Event> for Event {
fn from(e: dcutr::behaviour::Event) -> Self {
impl From<dcutr::Event> for Event {
fn from(e: dcutr::Event) -> Self {
Event::Dcutr(e)
}
}
Expand All @@ -157,7 +157,7 @@ fn main() -> Result<(), Box<dyn Error>> {
"/TODO/0.0.1".to_string(),
local_key.public(),
)),
dcutr: dcutr::behaviour::Behaviour::new(local_peer_id),
dcutr: dcutr::Behaviour::new(local_peer_id),
};

let mut swarm = match ThreadPool::new() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ pub enum Event {
},
DirectConnectionUpgradeFailed {
remote_peer_id: PeerId,
error: UpgradeError,
error: Error,
},
}

#[derive(Debug, Error)]
pub enum UpgradeError {
pub enum Error {
#[error("Failed to dial peer.")]
Dial,
#[error("Failed to establish substream: {0}.")]
Expand Down Expand Up @@ -164,7 +164,7 @@ impl Behaviour {
.into(),
NetworkBehaviourAction::GenerateEvent(Event::DirectConnectionUpgradeFailed {
remote_peer_id: peer_id,
error: UpgradeError::Dial,
error: Error::Dial,
})
.into(),
]);
Expand Down Expand Up @@ -236,7 +236,7 @@ impl NetworkBehaviour for Behaviour {
self.queued_actions.push_back(
NetworkBehaviourAction::GenerateEvent(Event::DirectConnectionUpgradeFailed {
remote_peer_id: event_source,
error: UpgradeError::Handler(error),
error: Error::Handler(error),
})
.into(),
);
Expand All @@ -260,7 +260,7 @@ impl NetworkBehaviour for Behaviour {
self.queued_actions.push_back(
NetworkBehaviourAction::GenerateEvent(Event::DirectConnectionUpgradeFailed {
remote_peer_id: event_source,
error: UpgradeError::Handler(error),
error: Error::Handler(error),
})
.into(),
);
Expand Down
35 changes: 32 additions & 3 deletions protocols/dcutr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,43 @@

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

pub mod behaviour;
mod behaviour_impl; // TODO: Rename back `behaviour` once deprecation symbols are removed.
mod handler;
mod protocol;
#[allow(clippy::derive_partial_eq_without_eq)]
mod message_proto {
include!(concat!(env!("OUT_DIR"), "/holepunch.pb.rs"));
}

pub use behaviour_impl::Behaviour;
pub use behaviour_impl::Error;
pub use behaviour_impl::Event;
pub use protocol::PROTOCOL_NAME;
pub type InboundUpgradeError = protocol::inbound::UpgradeError;
pub type OutboundUpgradeError = protocol::outbound::UpgradeError;
pub mod inbound {
pub use crate::protocol::inbound::UpgradeError;
}
pub mod outbound {
pub use crate::protocol::outbound::UpgradeError;
}

#[deprecated(
since = "0.9.0",
note = "Use `libp2p_dcutr::inbound::UpgradeError` instead.`"
)]
pub type InboundUpgradeError = inbound::UpgradeError;

#[deprecated(
since = "0.9.0",
note = "Use `libp2p_dcutr::outbound::UpgradeError` instead.`"
)]
pub type OutboundUpgradeError = outbound::UpgradeError;
pub mod behaviour {
#[deprecated(since = "0.9.0", note = "Use `libp2p_dcutr::Behaviour` instead.`")]
pub type Behaviour = crate::Behaviour;

#[deprecated(since = "0.9.0", note = "Use `libp2p_dcutr::Event` instead.`")]
pub type Event = crate::Event;

#[deprecated(since = "0.9.0", note = "Use `libp2p_dcutr::Error` instead.`")]
pub type UpgradeError = crate::Error;
}
14 changes: 7 additions & 7 deletions protocols/dcutr/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn connect() {

pool.run_until(wait_for_connection_established(&mut src, &dst_relayed_addr));
match pool.run_until(wait_for_dcutr_event(&mut src)) {
dcutr::behaviour::Event::RemoteInitiatedDirectConnectionUpgrade {
dcutr::Event::RemoteInitiatedDirectConnectionUpgrade {
remote_peer_id,
remote_relayed_addr,
} if remote_peer_id == dst_peer_id && remote_relayed_addr == dst_relayed_addr => {}
Expand Down Expand Up @@ -126,7 +126,7 @@ fn build_client() -> Swarm<Client> {
transport,
Client {
relay: behaviour,
dcutr: dcutr::behaviour::Behaviour::new(local_peer_id),
dcutr: dcutr::Behaviour::new(local_peer_id),
},
local_peer_id,
)
Expand Down Expand Up @@ -154,13 +154,13 @@ where
)]
struct Client {
relay: client::Client,
dcutr: dcutr::behaviour::Behaviour,
dcutr: dcutr::Behaviour,
}

#[derive(Debug)]
enum ClientEvent {
Relay(client::Event),
Dcutr(dcutr::behaviour::Event),
Dcutr(dcutr::Event),
}

impl From<client::Event> for ClientEvent {
Expand All @@ -169,8 +169,8 @@ impl From<client::Event> for ClientEvent {
}
}

impl From<dcutr::behaviour::Event> for ClientEvent {
fn from(event: dcutr::behaviour::Event) -> Self {
impl From<dcutr::Event> for ClientEvent {
fn from(event: dcutr::Event) -> Self {
ClientEvent::Dcutr(event)
}
}
Expand Down Expand Up @@ -241,7 +241,7 @@ async fn wait_for_new_listen_addr(client: &mut Swarm<Client>, new_addr: &Multiad
}
}

async fn wait_for_dcutr_event(client: &mut Swarm<Client>) -> dcutr::behaviour::Event {
async fn wait_for_dcutr_event(client: &mut Swarm<Client>) -> dcutr::Event {
loop {
match client.select_next_some().await {
SwarmEvent::Behaviour(ClientEvent::Dcutr(e)) => return e,
Expand Down