don't print peer logs on shutdown (#2341)

This commit is contained in:
Alex Sharov 2021-07-11 09:16:17 +00:00 committed by GitHub
parent 188dfb14b8
commit b38d3fc34b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -249,6 +249,11 @@ func runPeer(
printTime := time.Now().Add(time.Minute)
peerPrinted := false
defer func() {
select { // don't print logs if we stopping
case <-ctx.Done():
return
default:
}
if peerPrinted {
log.Info(fmt.Sprintf("Peer %s [%s] disconnected", peerID, peerInfo.peer.Fullname()), "proto", protocol)
}