Repository: libp2p/go-libp2p
Pull request #2694 (2024-01-28 07:50:06)

chore: fix typos


Patch:
diff --git a/p2p/net/reuseport/dialer.go b/p2p/net/reuseport/dialer.go
index 2efc02d3..ec3769a7 100644
--- a/p2p/net/reuseport/dialer.go
+++ b/p2p/net/reuseport/dialer.go
@@ -33,7 +33,7 @@ func randAddr(addrs []*net.TCPAddr) *net.TCPAddr {
 //
 // In-order:
 //
-//  1. If we're _explicitly_ listening on the prefered source address for the destination address
+//  1. If we're _explicitly_ listening on the preferred source address for the destination address
 //     (per the system's routes), we'll use that listener's port as the source port.
 //  2. If we're listening on one or more _unspecified_ addresses (zero address), we'll pick a source
 //     port from one of these listener's.
diff --git a/p2p/net/swarm/swarm_dial.go b/p2p/net/swarm/swarm_dial.go
index 3fb15383..f639ce16 100644
--- a/p2p/net/swarm/swarm_dial.go
+++ b/p2p/net/swarm/swarm_dial.go
@@ -426,7 +426,7 @@ var quicDraft29DialMatcher = mafmt.And(mafmt.IP, mafmt.Base(ma.P_UDP), mafmt.Bas
 // filterKnownUndialables takes a list of multiaddrs, and removes those
 // that we definitely don't want to dial: addresses configured to be blocked,
 // IPv6 link-local addresses, addresses without a dial-capable transport,
-// addresses that we know to be our own, and addresses with a better tranport
+// addresses that we know to be our own, and addresses with a better transport
 // available. This is an optimization to avoid wasting time on dials that we
 // know are going to fail or for which we have a better alternative.
 func (s *Swarm) filterKnownUndialables(p peer.ID, addrs []ma.Multiaddr) (goodAddrs []ma.Multiaddr, addrErrs []TransportError) {
@@ -546,7 +546,7 @@ func (s *Swarm) dialAddr(ctx context.Context, p peer.ID, addr ma.Multiaddr, updC
 	}
 
 	// We're recording any error as a failure here.
-	// Notably, this also applies to cancelations (i.e. if another dial attempt was faster).
+	// Notably, this also applies to cancellations (i.e. if another dial attempt was faster).
 	// This is ok since the black hole detector uses a very low threshold (5%).
 	s.bhd.RecordResult(addr, err == nil)
 
diff --git a/p2p/net/upgrader/listener.go b/p2p/net/upgrader/listener.go
index 0871d2f5..8af2791b 100644
--- a/p2p/net/upgrader/listener.go
+++ b/p2p/net/upgrader/listener.go
@@ -37,7 +37,7 @@ type listener struct {
 
 // Close closes the listener.
 func (l *listener) Close() error {
-	// Do this first to try to get any relevent errors.
+	// Do this first to try to get any relevant errors.
 	err := l.Listener.Close()
 
 	l.cancel()
diff --git a/p2p/protocol/circuitv2/relay/relay.go b/p2p/protocol/circuitv2/relay/relay.go
index b0e90469..0ad36168 100644
--- a/p2p/protocol/circuitv2/relay/relay.go
+++ b/p2p/protocol/circuitv2/relay/relay.go
@@ -295,7 +295,7 @@ func (r *Relay) handleConnect(s network.Stream, msg *pbv2.HopMessage) pbv2.Statu
 	destConns := r.conns[dest.ID]
 	if destConns >= r.rc.MaxCircuits {
 		r.mx.Unlock()
-		log.Debugf("refusing connection from %s to %s; too many connecitons to %s", src, dest.ID, dest.ID)
+		log.Debugf("refusing connection from %s to %s; too many connections to %s", src, dest.ID, dest.ID)
 		fail(pbv2.Status_RESOURCE_LIMIT_EXCEEDED)
 		return pbv2.Status_RESOURCE_LIMIT_EXCEEDED
 	}


Test patch:
diff --git a/p2p/http/example_test.go b/p2p/http/example_test.go
index f0b49b0e..bad042e9 100644
--- a/p2p/http/example_test.go
+++ b/p2p/http/example_test.go
@@ -61,6 +61,8 @@ func ExampleHost_listenOnHTTPTransportAndStreams() {
 	if err != nil {
 		log.Fatal(err)
 	}
+	defer serverStreamHost.Close()
+
 	server := libp2phttp.Host{
 		InsecureAllowHTTP: true, // For our example, we'll allow insecure HTTP
 		ListenAddrs:       []ma.Multiaddr{ma.StringCast("/ip4/127.0.0.1/tcp/50124/http")},