Skip to content

Commit

Permalink
fix(swarm): log local peer ID correctly
Browse files Browse the repository at this point in the history
This was an oversight in #4120, where we changed the creation of `Swarm`. Thus, all usages of the new `SwarmBuilder` did not actually hit this log line.

Pull-Request: #4671.
  • Loading branch information
thomaseizinger committed Oct 25, 2023
1 parent 7305234 commit 85e6105
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
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

0 comments on commit 85e6105

Please sign in to comment.