Skip to content

Commit 85e6105

Browse files
fix(swarm): log local peer ID correctly
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.
1 parent 7305234 commit 85e6105

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

swarm/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- Don't close entire connection upon `DialUpgradeError`s within `OneShotHandler`.
1212
Instead, the error is reported as `Err(e)` via `ConnectionHandler::ToBehaviour`.
1313
See [PR 4715](https://github.com/libp2p/rust-libp2p/pull/4715).
14+
- Log `PeerId` of `Swarm` even when constructed with new `SwarmBuilder`.
15+
See [PR 4671](https://github.com/libp2p/rust-libp2p/pull/4671).
1416

1517
## 0.43.6
1618

swarm/src/lib.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ where
366366
local_peer_id: PeerId,
367367
config: Config,
368368
) -> Self {
369+
log::info!("Local peer id: {local_peer_id}");
370+
369371
Swarm {
370372
local_peer_id,
371373
transport,
@@ -1656,17 +1658,14 @@ where
16561658

16571659
/// Builds a `Swarm` with the current configuration.
16581660
pub fn build(self) -> Swarm<TBehaviour> {
1659-
log::info!("Local peer id: {}", self.local_peer_id);
1660-
Swarm {
1661-
local_peer_id: self.local_peer_id,
1662-
transport: self.transport,
1663-
pool: Pool::new(self.local_peer_id, self.pool_config),
1664-
behaviour: self.behaviour,
1665-
supported_protocols: Default::default(),
1666-
confirmed_external_addr: Default::default(),
1667-
listened_addrs: HashMap::new(),
1668-
pending_event: None,
1669-
}
1661+
Swarm::new(
1662+
self.transport,
1663+
self.behaviour,
1664+
self.local_peer_id,
1665+
Config {
1666+
pool_config: self.pool_config,
1667+
},
1668+
)
16701669
}
16711670
}
16721671

0 commit comments

Comments
 (0)