mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 03:41:45 +00:00
logs: distinguish WARN and INFO for peer disconnected
Peer disconnections are not warnings in some cases. Close #3182 Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
parent
836183ecb6
commit
4a5e8f8592
1 changed files with 19 additions and 11 deletions
|
@ -44,12 +44,13 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errAlreadyConnected = errors.New("already connected")
|
errAlreadyConnected = errors.New("already connected")
|
||||||
errIdenticalID = errors.New("identical node id")
|
errIdenticalID = errors.New("identical node id")
|
||||||
errInvalidNetwork = errors.New("invalid network")
|
errInvalidNetwork = errors.New("invalid network")
|
||||||
errMaxPeers = errors.New("max peers reached")
|
errMaxPeers = errors.New("max peers reached")
|
||||||
errServerShutdown = errors.New("server shutdown")
|
errServerShutdown = errors.New("server shutdown")
|
||||||
errInvalidInvType = errors.New("invalid inventory type")
|
errInvalidInvType = errors.New("invalid inventory type")
|
||||||
|
errBlocksRequestFailed = errors.New("blocks request failed")
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -512,10 +513,17 @@ func (s *Server) run() {
|
||||||
if s.peers[drop.peer] {
|
if s.peers[drop.peer] {
|
||||||
delete(s.peers, drop.peer)
|
delete(s.peers, drop.peer)
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
s.log.Warn("peer disconnected",
|
if errors.Is(drop.reason, errInvalidInvType) || errors.Is(drop.reason, errStateMismatch) || errors.Is(drop.reason, errBlocksRequestFailed) {
|
||||||
zap.Stringer("addr", drop.peer.RemoteAddr()),
|
s.log.Warn("peer disconnected",
|
||||||
zap.Error(drop.reason),
|
zap.Stringer("addr", drop.peer.RemoteAddr()),
|
||||||
zap.Int("peerCount", s.PeerCount()))
|
zap.Error(drop.reason),
|
||||||
|
zap.Int("peerCount", s.PeerCount()))
|
||||||
|
} else {
|
||||||
|
s.log.Info("peer disconnected",
|
||||||
|
zap.Stringer("addr", drop.peer.RemoteAddr()),
|
||||||
|
zap.Error(drop.reason),
|
||||||
|
zap.Int("peerCount", s.PeerCount()))
|
||||||
|
}
|
||||||
if errors.Is(drop.reason, errIdenticalID) {
|
if errors.Is(drop.reason, errIdenticalID) {
|
||||||
s.discovery.RegisterSelf(drop.peer)
|
s.discovery.RegisterSelf(drop.peer)
|
||||||
} else {
|
} else {
|
||||||
|
@ -793,7 +801,7 @@ func (s *Server) requestBlocksOrHeaders(p Peer) error {
|
||||||
}
|
}
|
||||||
err := s.requestBlocks(bq, p)
|
err := s.requestBlocks(bq, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("%w: %w", errBlocksRequestFailed, err)
|
||||||
}
|
}
|
||||||
if requestMPTNodes {
|
if requestMPTNodes {
|
||||||
return s.requestMPTNodes(p, s.stateSync.GetUnknownMPTNodesBatch(payload.MaxMPTHashesCount))
|
return s.requestMPTNodes(p, s.stateSync.GetUnknownMPTNodesBatch(payload.MaxMPTHashesCount))
|
||||||
|
|
Loading…
Reference in a new issue