From f9bc22ec6a35c205c366e6b62f13f97be62f941f Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 20 Nov 2017 21:36:01 +0000 Subject: [PATCH] p2p: fix comment on addPeer (thanks @odeke-em) --- p2p/switch.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/p2p/switch.go b/p2p/switch.go index b56e84a81..23733ccbc 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -212,7 +212,7 @@ func (sw *Switch) OnStop() { // addPeer checks the given peer's validity, performs a handshake, and adds the // peer to the switch and to all registered reactors. // NOTE: This performs a blocking handshake before the peer is added. -// CONTRACT: If error is returned, peer is nil, and conn is immediately closed. +// NOTE: If error is returned, caller is responsible for calling peer.CloseConn() func (sw *Switch) addPeer(peer *peer) error { if err := sw.FilterConnByAddr(peer.Addr()); err != nil { @@ -570,7 +570,7 @@ func (sw *Switch) addPeerWithConnection(conn net.Conn) error { } peer.SetLogger(sw.Logger.With("peer", conn.RemoteAddr())) if err = sw.addPeer(peer); err != nil { - conn.Close() + peer.CloseConn() return err } @@ -585,7 +585,7 @@ func (sw *Switch) addPeerWithConnectionAndConfig(conn net.Conn, config *PeerConf } peer.SetLogger(sw.Logger.With("peer", conn.RemoteAddr())) if err = sw.addPeer(peer); err != nil { - conn.Close() + peer.CloseConn() return err }