From d18e536cc119f44a37c65a5c48a778c428dba1af Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Mon, 5 Aug 2024 19:53:32 +0200 Subject: [PATCH] resolving problems --- hole-punching-tests/Cargo.toml | 2 +- interop-tests/Cargo.toml | 4 +- protocols/perf/Cargo.toml | 2 +- swarm-derive/src/experimental.rs | 9 ---- swarm-test/Cargo.toml | 2 +- swarm/bench.backup.txt | 73 -------------------------------- swarm/src/lib.rs | 65 +++++++++++++++------------- 7 files changed, 41 insertions(+), 116 deletions(-) delete mode 100644 swarm/bench.backup.txt diff --git a/hole-punching-tests/Cargo.toml b/hole-punching-tests/Cargo.toml index 79728f9535c..6f471491277 100644 --- a/hole-punching-tests/Cargo.toml +++ b/hole-punching-tests/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" anyhow = "1" env_logger = "0.10.2" futures = { workspace = true } -libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] } +libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "experimental-macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] } tracing = { workspace = true } redis = { version = "0.24.0", default-features = false, features = ["tokio-comp"] } tokio = { workspace = true, features = ["full"] } diff --git a/interop-tests/Cargo.toml b/interop-tests/Cargo.toml index 0eb32bb4975..f62d08828ea 100644 --- a/interop-tests/Cargo.toml +++ b/interop-tests/Cargo.toml @@ -22,7 +22,7 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] axum = "0.7" -libp2p = { path = "../libp2p", features = [ "ping", "noise", "tls", "rsa", "macros", "websocket", "tokio", "yamux", "tcp", "dns", "identify", "quic"] } +libp2p = { path = "../libp2p", features = [ "ping", "noise", "tls", "rsa", "experimental-macros", "websocket", "tokio", "yamux", "tcp", "dns", "identify", "quic"] } libp2p-mplex = { path = "../muxers/mplex" } libp2p-noise = { workspace = true } libp2p-tls = { workspace = true } @@ -40,7 +40,7 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["env-filter"] } [target.'cfg(target_arch = "wasm32")'.dependencies] -libp2p = { path = "../libp2p", features = [ "ping", "macros", "webtransport-websys", "wasm-bindgen", "identify", "websocket-websys", "yamux", "noise"] } +libp2p = { path = "../libp2p", features = [ "ping", "experimental-macros", "webtransport-websys", "wasm-bindgen", "identify", "websocket-websys", "yamux", "noise"] } libp2p-mplex = { path = "../muxers/mplex" } libp2p-webrtc-websys = { workspace = true } wasm-bindgen = { version = "0.2" } diff --git a/protocols/perf/Cargo.toml b/protocols/perf/Cargo.toml index c5dd7dc3456..abe58088caa 100644 --- a/protocols/perf/Cargo.toml +++ b/protocols/perf/Cargo.toml @@ -22,7 +22,7 @@ libp2p-core = { workspace = true } libp2p-dns = { workspace = true, features = ["tokio"] } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-quic = { workspace = true, features = ["tokio"] } -libp2p-swarm = { workspace = true, features = ["experimental-macros", "macros", "tokio"] } +libp2p-swarm = { workspace = true, features = ["macros", "tokio"] } libp2p-tcp = { workspace = true, features = ["tokio"] } libp2p-tls = { workspace = true } libp2p-yamux = { workspace = true } diff --git a/swarm-derive/src/experimental.rs b/swarm-derive/src/experimental.rs index 8845b80425e..018877efdbd 100644 --- a/swarm-derive/src/experimental.rs +++ b/swarm-derive/src/experimental.rs @@ -360,15 +360,6 @@ pub(crate) fn build_struct( ) -> std::task::Poll< #connection_handler_event, > { - // #( - // if let std::task::Poll::Ready(event) = self.#fields.poll(cx) { - // return std::task::Poll::Ready(event - // .map_custom(#to_beh::#var_names) - // .map_outbound_open_info(#ooi::#var_names) - // .map_protocol(#ou::#var_names)); - // } - // )* - let mut fuel = #beh_count; while fuel > 0 { // save the poll position to avoid repolling exhaused handlers diff --git a/swarm-test/Cargo.toml b/swarm-test/Cargo.toml index e8313891899..1bd40bdace3 100644 --- a/swarm-test/Cargo.toml +++ b/swarm-test/Cargo.toml @@ -16,7 +16,7 @@ async-trait = "0.1.80" libp2p-core = { workspace = true } libp2p-identity = { workspace = true, features = ["rand"] } libp2p-plaintext = { workspace = true } -libp2p-swarm = { workspace = true, features = ["experimental-macros", "async-std"] } +libp2p-swarm = { workspace = true, features = ["async-std"] } libp2p-tcp = { workspace = true, features = ["async-io"] } libp2p-yamux = { workspace = true } futures = { workspace = true } diff --git a/swarm/bench.backup.txt b/swarm/bench.backup.txt deleted file mode 100644 index 73a0df6359e..00000000000 --- a/swarm/bench.backup.txt +++ /dev/null @@ -1,73 +0,0 @@ - Compiling proc-macro2 v1.0.85 - Compiling unicode-ident v1.0.11 - Compiling cfg-if v1.0.0 - Compiling autocfg v1.1.0 - Compiling libc v0.2.155 - Compiling pin-project-lite v0.2.14 - Compiling memchr v2.7.2 - Compiling futures-core v0.3.30 - Compiling version_check v0.9.4 - Compiling futures-io v0.3.30 - Compiling once_cell v1.19.0 - Compiling crossbeam-utils v0.8.16 - Compiling pin-utils v0.1.0 - Compiling value-bag v1.7.0 - Compiling futures-sink v0.3.30 - Compiling futures-task v0.3.30 - Compiling typenum v1.16.0 - Compiling serde v1.0.203 - Compiling byteorder v1.5.0 - Compiling thiserror v1.0.61 - Compiling parking v2.1.0 - Compiling futures-channel v0.3.30 - Compiling scopeguard v1.2.0 - Compiling semver v1.0.18 - Compiling slab v0.4.8 - Compiling bytes v1.6.0 - Compiling generic-array v0.14.7 - Compiling tracing-core v0.1.32 - Compiling event-listener v2.5.3 - Compiling ppv-lite86 v0.2.17 - Compiling syn v1.0.109 - Compiling subtle v2.5.0 - Compiling waker-fn v1.1.0 - Compiling io-lifetimes v1.0.11 - Compiling fastrand v1.9.0 - Compiling log v0.4.21 - Compiling bitflags v1.3.2 - Compiling polling v2.8.0 - Compiling rustix v0.37.25 - Compiling smallvec v1.13.2 - Compiling lock_api v0.4.10 - Compiling rustc_version v0.4.0 - Compiling async-io v1.13.0 - Compiling async-lock v2.7.0 - Compiling concurrent-queue v2.2.0 - Compiling linux-raw-sys v0.3.8 - Compiling static_assertions v1.1.0 - Compiling cpufeatures v0.2.9 - Compiling parking_lot_core v0.9.8 - Compiling quote v1.0.36 - Compiling tinyvec_macros v0.1.1 - Compiling ahash v0.8.7 - Compiling zeroize v1.8.1 - Compiling either v1.12.0 - Compiling data-encoding v2.6.0 - Compiling signature v2.1.0 - Compiling curve25519-dalek v4.1.3 - Compiling futures-lite v1.13.0 - Compiling tinyvec v1.6.0 - Compiling core2 v0.4.0 - Compiling quick-protobuf v0.8.1 - Compiling ed25519 v2.2.2 - Compiling unicode-bidi v0.3.13 - Compiling unsigned-varint v0.7.2 - Compiling syn v2.0.66 - Compiling percent-encoding v2.3.1 - Compiling zerocopy v0.7.32 - Compiling async-task v4.4.0 - Compiling multihash v0.19.1 - Compiling async-channel v1.9.0 - Compiling allocator-api2 v0.2.16 - Compiling form_urlencoded v1.2.1 - Compiling base-x v0.2.11 diff --git a/swarm/src/lib.rs b/swarm/src/lib.rs index 64d5c3edc9e..a89b3f7d2fa 100644 --- a/swarm/src/lib.rs +++ b/swarm/src/lib.rs @@ -122,35 +122,42 @@ pub mod derive_prelude { pub use libp2p_core::Multiaddr; pub use libp2p_identity::PeerId; - pub type TBehaviourOutEvent = ::ToSwarm; - pub type THandlerInProtocol = - as ConnectionHandler>::InboundProtocol; - pub type THandlerInOpenInfo = - as ConnectionHandler>::InboundOpenInfo; - pub type THandlerOutProtocol = - as ConnectionHandler>::OutboundProtocol; - pub type THandlerOutOpenInfo = - as ConnectionHandler>::OutboundOpenInfo; - pub type THandlerInUpgradeInfo = - as UpgradeInfoSend>::Info; - pub type THandlerOutUpgradeInfo = - as UpgradeInfoSend>::Info; - pub type THandlerInUpgradeInfoIter = - as UpgradeInfoSend>::InfoIter; - pub type THandlerOutUpgradeInfoIter = - as UpgradeInfoSend>::InfoIter; - pub type THandlerInUpgradeOutput = - as InboundUpgradeSend>::Output; - pub type THandlerOutUpgradeOutput = - as OutboundUpgradeSend>::Output; - pub type THandlerInUpgradeError = - as InboundUpgradeSend>::Error; - pub type THandlerOutUpgradeError = - as OutboundUpgradeSend>::Error; - pub type THandlerInUpgradeFuture = - as InboundUpgradeSend>::Future; - pub type THandlerOutUpgradeFuture = - as OutboundUpgradeSend>::Future; + #[cfg(feature = "experimental-macros")] + #[doc(hidden)] + pub mod experimental { + use super::*; + pub type TBehaviourOutEvent = ::ToSwarm; + pub type THandlerInProtocol = + as ConnectionHandler>::InboundProtocol; + pub type THandlerInOpenInfo = + as ConnectionHandler>::InboundOpenInfo; + pub type THandlerOutProtocol = + as ConnectionHandler>::OutboundProtocol; + pub type THandlerOutOpenInfo = + as ConnectionHandler>::OutboundOpenInfo; + pub type THandlerInUpgradeInfo = + as UpgradeInfoSend>::Info; + pub type THandlerOutUpgradeInfo = + as UpgradeInfoSend>::Info; + pub type THandlerInUpgradeInfoIter = + as UpgradeInfoSend>::InfoIter; + pub type THandlerOutUpgradeInfoIter = + as UpgradeInfoSend>::InfoIter; + pub type THandlerInUpgradeOutput = + as InboundUpgradeSend>::Output; + pub type THandlerOutUpgradeOutput = + as OutboundUpgradeSend>::Output; + pub type THandlerInUpgradeError = + as InboundUpgradeSend>::Error; + pub type THandlerOutUpgradeError = + as OutboundUpgradeSend>::Error; + pub type THandlerInUpgradeFuture = + as InboundUpgradeSend>::Future; + pub type THandlerOutUpgradeFuture = + as OutboundUpgradeSend>::Future; + } + #[cfg(feature = "experimental-macros")] + pub use experimental::*; } pub use behaviour::{