mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 16:37:39 +00:00
p2p.AddConnectionHandler: Remove unused arg for goodbyeFunc (#6511)
* p2p.AddConnectionHandler: Remove unused arg for goodbyeFunc * accidental rename reqFunc * update test * Merge branch 'master' into rm-unused-param * Merge branch 'master' into rm-unused-param
This commit is contained in:
parent
d53ab16004
commit
1067800430
@ -26,9 +26,7 @@ func peerMultiaddrString(conn network.Conn) string {
|
|||||||
// AddConnectionHandler adds a callback function which handles the connection with a
|
// AddConnectionHandler adds a callback function which handles the connection with a
|
||||||
// newly added peer. It performs a handshake with that peer by sending a hello request
|
// newly added peer. It performs a handshake with that peer by sending a hello request
|
||||||
// and validating the response from the peer.
|
// and validating the response from the peer.
|
||||||
func (s *Service) AddConnectionHandler(reqFunc func(ctx context.Context, id peer.ID) error,
|
func (s *Service) AddConnectionHandler(reqFunc func(ctx context.Context, id peer.ID) error) {
|
||||||
goodbyeFunc func(ctx context.Context, id peer.ID) error) {
|
|
||||||
|
|
||||||
// Peer map and lock to keep track of current connection attempts.
|
// Peer map and lock to keep track of current connection attempts.
|
||||||
peerMap := make(map[peer.ID]bool)
|
peerMap := make(map[peer.ID]bool)
|
||||||
peerLock := new(sync.Mutex)
|
peerLock := new(sync.Mutex)
|
||||||
|
@ -42,7 +42,7 @@ type SetStreamHandler interface {
|
|||||||
|
|
||||||
// ConnectionHandler configures p2p to handle connections with a peer.
|
// ConnectionHandler configures p2p to handle connections with a peer.
|
||||||
type ConnectionHandler interface {
|
type ConnectionHandler interface {
|
||||||
AddConnectionHandler(f func(ctx context.Context, id peer.ID) error, g func(context.Context, peer.ID) error)
|
AddConnectionHandler(f func(ctx context.Context, id peer.ID) error)
|
||||||
AddDisconnectionHandler(f func(ctx context.Context, id peer.ID) error)
|
AddDisconnectionHandler(f func(ctx context.Context, id peer.ID) error)
|
||||||
connmgr.ConnectionGater
|
connmgr.ConnectionGater
|
||||||
}
|
}
|
||||||
|
@ -180,8 +180,7 @@ func (p *TestP2P) ENR() *enr.Record {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddConnectionHandler handles the connection with a newly connected peer.
|
// AddConnectionHandler handles the connection with a newly connected peer.
|
||||||
func (p *TestP2P) AddConnectionHandler(f func(ctx context.Context, id peer.ID) error,
|
func (p *TestP2P) AddConnectionHandler(f func(ctx context.Context, id peer.ID) error) {
|
||||||
g func(context.Context, peer.ID) error) {
|
|
||||||
p.BHost.Network().Notify(&network.NotifyBundle{
|
p.BHost.Network().Notify(&network.NotifyBundle{
|
||||||
ConnectedF: func(net network.Network, conn network.Conn) {
|
ConnectedF: func(net network.Network, conn network.Conn) {
|
||||||
// Must be handled in a goroutine as this callback cannot be blocking.
|
// Must be handled in a goroutine as this callback cannot be blocking.
|
||||||
|
@ -499,7 +499,7 @@ func TestStatusRPCRequest_RequestSent(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
p1.AddConnectionHandler(r.sendRPCStatusRequest, r.sendGenericGoodbyeMessage)
|
p1.AddConnectionHandler(r.sendRPCStatusRequest)
|
||||||
p1.Connect(p2)
|
p1.Connect(p2)
|
||||||
|
|
||||||
if testutil.WaitTimeout(&wg, 1*time.Second) {
|
if testutil.WaitTimeout(&wg, 1*time.Second) {
|
||||||
@ -597,7 +597,7 @@ func TestStatusRPCRequest_FinalizedBlockExists(t *testing.T) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
p1.AddConnectionHandler(r.sendRPCStatusRequest, r.sendGenericGoodbyeMessage)
|
p1.AddConnectionHandler(r.sendRPCStatusRequest)
|
||||||
p1.Connect(p2)
|
p1.Connect(p2)
|
||||||
|
|
||||||
if testutil.WaitTimeout(&wg, 100*time.Second) {
|
if testutil.WaitTimeout(&wg, 100*time.Second) {
|
||||||
|
@ -148,7 +148,7 @@ func (s *Service) Start() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
s.p2p.AddConnectionHandler(s.reValidatePeer, s.sendGenericGoodbyeMessage)
|
s.p2p.AddConnectionHandler(s.reValidatePeer)
|
||||||
s.p2p.AddDisconnectionHandler(func(_ context.Context, _ peer.ID) error {
|
s.p2p.AddDisconnectionHandler(func(_ context.Context, _ peer.ID) error {
|
||||||
// no-op
|
// no-op
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user