Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SwarmBuilder): make with_bandwidth_logging chainable #4643

Open
mxinden opened this issue Oct 13, 2023 · 0 comments
Open

feat(SwarmBuilder): make with_bandwidth_logging chainable #4643

mxinden opened this issue Oct 13, 2023 · 0 comments

Comments

@mxinden
Copy link
Member

mxinden commented Oct 13, 2023

Description

SwarmBuilder::with_bandwidth_logging allows adding a bandwidth logging to a tree of transports constructed via SwarmBuilder. It returns both the builder and the BandwidthSinks. That is not ideal as it breaks the builder chain.

This originally came up in #4120 (comment).

Motivation

A single continuous builder chain is more ergonomic.

Current Implementation

The current with_bandwidth_logging requires a two step builder flow:

let (builder, _bandwidth_sinks) = SwarmBuilder::with_new_identity()
.with_tokio()
.with_tcp(
Default::default(),
libp2p_tls::Config::new,
libp2p_yamux::Config::default,
)
.unwrap()
.with_quic()
.with_dns()
.unwrap()
.with_relay_client(libp2p_tls::Config::new, libp2p_yamux::Config::default)
.unwrap()
.with_websocket(libp2p_tls::Config::new, libp2p_yamux::Config::default)
.await
.unwrap()
.with_bandwidth_logging();
let _: Swarm<MyBehaviour> = builder
.with_behaviour(|_key, relay| MyBehaviour { relay })
.unwrap()
.build();
}

See also #4626 (comment).

Are you planning to do it yourself in a pull request ?

No

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

No branches or pull requests

1 participant