From 1067800430b8d94841d5bfd37f568d9bf7387b98 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Tue, 7 Jul 2020 19:04:15 -0700 Subject: [PATCH] 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 --- beacon-chain/p2p/handshake.go | 4 +--- beacon-chain/p2p/interfaces.go | 2 +- beacon-chain/p2p/testing/p2p.go | 3 +-- beacon-chain/sync/rpc_status_test.go | 4 ++-- beacon-chain/sync/service.go | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/beacon-chain/p2p/handshake.go b/beacon-chain/p2p/handshake.go index 13e688ce3..e382d76b9 100644 --- a/beacon-chain/p2p/handshake.go +++ b/beacon-chain/p2p/handshake.go @@ -26,9 +26,7 @@ func peerMultiaddrString(conn network.Conn) string { // 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 // and validating the response from the peer. -func (s *Service) AddConnectionHandler(reqFunc func(ctx context.Context, id peer.ID) error, - goodbyeFunc func(ctx context.Context, id peer.ID) error) { - +func (s *Service) AddConnectionHandler(reqFunc func(ctx context.Context, id peer.ID) error) { // Peer map and lock to keep track of current connection attempts. peerMap := make(map[peer.ID]bool) peerLock := new(sync.Mutex) diff --git a/beacon-chain/p2p/interfaces.go b/beacon-chain/p2p/interfaces.go index f0d0cbc80..c4130fb2d 100644 --- a/beacon-chain/p2p/interfaces.go +++ b/beacon-chain/p2p/interfaces.go @@ -42,7 +42,7 @@ type SetStreamHandler interface { // ConnectionHandler configures p2p to handle connections with a peer. 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) connmgr.ConnectionGater } diff --git a/beacon-chain/p2p/testing/p2p.go b/beacon-chain/p2p/testing/p2p.go index 67e77900b..1058cba96 100644 --- a/beacon-chain/p2p/testing/p2p.go +++ b/beacon-chain/p2p/testing/p2p.go @@ -180,8 +180,7 @@ func (p *TestP2P) ENR() *enr.Record { } // AddConnectionHandler handles the connection with a newly connected peer. -func (p *TestP2P) AddConnectionHandler(f func(ctx context.Context, id peer.ID) error, - g func(context.Context, peer.ID) error) { +func (p *TestP2P) AddConnectionHandler(f func(ctx context.Context, id peer.ID) error) { p.BHost.Network().Notify(&network.NotifyBundle{ ConnectedF: func(net network.Network, conn network.Conn) { // Must be handled in a goroutine as this callback cannot be blocking. diff --git a/beacon-chain/sync/rpc_status_test.go b/beacon-chain/sync/rpc_status_test.go index 2b2788563..33a27638f 100644 --- a/beacon-chain/sync/rpc_status_test.go +++ b/beacon-chain/sync/rpc_status_test.go @@ -499,7 +499,7 @@ func TestStatusRPCRequest_RequestSent(t *testing.T) { } }) - p1.AddConnectionHandler(r.sendRPCStatusRequest, r.sendGenericGoodbyeMessage) + p1.AddConnectionHandler(r.sendRPCStatusRequest) p1.Connect(p2) 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) if testutil.WaitTimeout(&wg, 100*time.Second) { diff --git a/beacon-chain/sync/service.go b/beacon-chain/sync/service.go index 554d86a83..33bce9ce4 100644 --- a/beacon-chain/sync/service.go +++ b/beacon-chain/sync/service.go @@ -148,7 +148,7 @@ func (s *Service) Start() { panic(err) } - s.p2p.AddConnectionHandler(s.reValidatePeer, s.sendGenericGoodbyeMessage) + s.p2p.AddConnectionHandler(s.reValidatePeer) s.p2p.AddDisconnectionHandler(func(_ context.Context, _ peer.ID) error { // no-op return nil