Skip to content

Commit

Permalink
basichost: add certhashes to addrs in place
Browse files Browse the repository at this point in the history
There is no reason to copy this slice. This is always called with
a new slice that's not shared with anything else.
  • Loading branch information
sukunrt committed Feb 18, 2025
1 parent 914331b commit f40b670
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions p2p/host/basic/basic_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,7 @@ func (h *BasicHost) AllAddrs() []ma.Multiaddr {
return finalAddrs
}

// addCertHashes adds certhashes to the relevant addresses. It modifies `addrs` in place.
func (h *BasicHost) addCertHashes(addrs []ma.Multiaddr) []ma.Multiaddr {
// This is a temporary workaround/hack that fixes #2233. Once we have a
// proper address pipeline, rework this. See the issue for more context.
Expand All @@ -1020,11 +1021,6 @@ func (h *BasicHost) addCertHashes(addrs []ma.Multiaddr) []ma.Multiaddr {
return addrs
}

// Copy addrs slice since we'll be modifying it.
addrsOld := addrs
addrs = make([]ma.Multiaddr, len(addrsOld))
copy(addrs, addrsOld)

for i, addr := range addrs {
wtOK, wtN := libp2pwebtransport.IsWebtransportMultiaddr(addr)
webrtcOK, webrtcN := libp2pwebrtc.IsWebRTCDirectMultiaddr(addr)
Expand Down

0 comments on commit f40b670

Please sign in to comment.