mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
move out of go-routine (#3883)
This commit is contained in:
parent
2b444ea954
commit
2785a6d5ee
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user