diff --git a/beacon-chain/p2p/handshake.go b/beacon-chain/p2p/handshake.go index b5fa4c288..78be07000 100644 --- a/beacon-chain/p2p/handshake.go +++ b/beacon-chain/p2p/handshake.go @@ -15,18 +15,19 @@ import ( func (s *Service) AddConnectionHandler(reqFunc func(ctx context.Context, id peer.ID) error) { s.host.Network().Notify(&network.NotifyBundle{ ConnectedF: func(net network.Network, conn network.Conn) { - // Must be handled in a goroutine as this callback cannot be blocking. - go func() { - if peerstatus.IsBadPeer(conn.RemotePeer()) { - // Add Peer to gossipsub blacklist - s.pubsub.BlacklistPeer(conn.RemotePeer()) - log.WithField("peerID", conn.RemotePeer().Pretty()).Debug("Disconnecting with bad peer") - if err := s.Disconnect(conn.RemotePeer()); err != nil { - log.WithError(err).Errorf("Unable to close peer %s", conn.RemotePeer()) - return - } + if peerstatus.IsBadPeer(conn.RemotePeer()) { + // Add Peer to gossipsub blacklist + s.pubsub.BlacklistPeer(conn.RemotePeer()) + log.WithField("peerID", conn.RemotePeer().Pretty()).Trace("Disconnecting with bad peer") + if err := s.Disconnect(conn.RemotePeer()); err != nil { + log.WithError(err).Errorf("Unable to close peer %s", conn.RemotePeer()) return } + return + } + + // Must be handled in a goroutine as this callback cannot be blocking. + go func() { ctx := context.Background() log := log.WithField("peer", conn.RemotePeer()) if conn.Stat().Direction == network.DirInbound {