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:
Preston Van Loon 2020-07-07 19:04:15 -07:00 committed by GitHub
parent d53ab16004
commit 1067800430
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 9 deletions

View File

@ -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)

View File

@ -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
}

View File

@ -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.

View File

@ -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) {

View File

@ -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