From 4f52a6de514c54d1d41c3cc0f6d980366240665b Mon Sep 17 00:00:00 2001 From: Svarog Date: Mon, 31 May 2021 10:50:12 +0300 Subject: [PATCH] Check if `err != nil` returned from ConnectionManager.Ban() (#1736) --- app/protocol/protocol.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/protocol/protocol.go b/app/protocol/protocol.go index daf94d713..be6e8d575 100644 --- a/app/protocol/protocol.go +++ b/app/protocol/protocol.go @@ -1,8 +1,6 @@ package protocol import ( - "github.com/kaspanet/kaspad/app/protocol/flows/rejects" - "github.com/kaspanet/kaspad/infrastructure/network/connmanager" "sync" "sync/atomic" @@ -11,10 +9,12 @@ import ( "github.com/kaspanet/kaspad/app/protocol/flows/blockrelay" "github.com/kaspanet/kaspad/app/protocol/flows/handshake" "github.com/kaspanet/kaspad/app/protocol/flows/ping" + "github.com/kaspanet/kaspad/app/protocol/flows/rejects" "github.com/kaspanet/kaspad/app/protocol/flows/transactionrelay" peerpkg "github.com/kaspanet/kaspad/app/protocol/peer" "github.com/kaspanet/kaspad/app/protocol/protocolerrors" "github.com/kaspanet/kaspad/infrastructure/network/addressmanager" + "github.com/kaspanet/kaspad/infrastructure/network/connmanager" "github.com/kaspanet/kaspad/infrastructure/network/netadapter" routerpkg "github.com/kaspanet/kaspad/infrastructure/network/netadapter/router" "github.com/pkg/errors" @@ -106,7 +106,7 @@ func (m *Manager) handleError(err error, netConnection *netadapter.NetConnection log.Warnf("Banning %s (reason: %s)", netConnection, protocolErr.Cause) err := m.context.ConnectionManager().Ban(netConnection) - if !errors.Is(err, connmanager.ErrCannotBanPermanent) { + if err != nil && !errors.Is(err, connmanager.ErrCannotBanPermanent) { panic(err) }