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

fix(swarm): log local peer ID correctly #4671

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions swarm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- Don't close entire connection upon `DialUpgradeError`s within `OneShotHandler`.
Instead, the error is reported as `Err(e)` via `ConnectionHandler::ToBehaviour`.
See [PR 4715](https://github.com/libp2p/rust-libp2p/pull/4715).
- Log `PeerId` of `Swarm` even when constructed with new `SwarmBuilder`.
See [PR 4671](https://github.com/libp2p/rust-libp2p/pull/4671).

## 0.43.6

Expand Down
21 changes: 10 additions & 11 deletions swarm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ where
local_peer_id: PeerId,
config: Config,
) -> Self {
log::info!("Local peer id: {local_peer_id}");

Swarm {
local_peer_id,
transport,
Expand Down Expand Up @@ -1656,17 +1658,14 @@ where

/// Builds a `Swarm` with the current configuration.
pub fn build(self) -> Swarm<TBehaviour> {
log::info!("Local peer id: {}", self.local_peer_id);
Swarm {
local_peer_id: self.local_peer_id,
transport: self.transport,
pool: Pool::new(self.local_peer_id, self.pool_config),
behaviour: self.behaviour,
supported_protocols: Default::default(),
confirmed_external_addr: Default::default(),
listened_addrs: HashMap::new(),
pending_event: None,
}
Swarm::new(
self.transport,
self.behaviour,
self.local_peer_id,
Config {
pool_config: self.pool_config,
},
)
}
}

Expand Down