libp2p / libp2p/rust-libp2p

feat(SwarmBuilder): make `with_bandwidth_logging` chainable

Open
#4,643 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.6k
Forks
1.3k
Avg merge
8h 47m
Merged PRs (30d)
19

Description

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 https://github.com/libp2p/rust-libp2p/pull/4120#discussion_r1314340085.

Motivation

A single continuous builder chain is more ergonomic.

Current Implementation

The current with_bandwidth_logging requires a two step builder flow:

https://github.com/libp2p/rust-libp2p/blob/56cb08a9b05e0fdb89404cb60b2453f6968b2836/libp2p/src/builder.rs#L300-L321

See also https://github.com/libp2p/rust-libp2p/pull/4626#discussion_r1355883313.

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

No

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in libp2p/src/builder.rs around the with_bandwidth_logging implementation at lines 300-321, and review the linked discussions for the intended builder API. Determine how the method can preserve access to BandwidthSinks without breaking a continuous chain; done means the builder remains chainable and bandwidth logging still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.