Fix for peer not found messages (#2181)

* Fix for peer not found messages

* Print proto on disconnects too

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
ledgerwatch 2021-06-16 17:18:19 +01:00 committed by GitHub
parent 1390b3c740
commit 8a166204b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,13 +250,13 @@ func runPeer(
peerPrinted := false
defer func() {
if peerPrinted {
log.Info(fmt.Sprintf("Peer %s [%s] disconnected", peerID, peerInfo.peer.Fullname()))
log.Info(fmt.Sprintf("Peer %s [%s] disconnected", peerID, peerInfo.peer.Fullname()), "proto", protocol)
}
}()
for {
if !peerPrinted {
if time.Now().After(printTime) {
log.Info(fmt.Sprintf("Peer %s [%s] stable", peerID, peerInfo.peer.Fullname()))
log.Info(fmt.Sprintf("Peer %s [%s] stable", peerID, peerInfo.peer.Fullname()), "proto", protocol)
peerPrinted = true
}
}
@ -501,6 +501,7 @@ func NewSentryServer(ctx context.Context, dialCandidates enode.Iterator, readNod
if err != nil {
return fmt.Errorf("handshake to peer %s: %v", peerID, err)
}
ss.Peers.Store(peerID, peerInfo) // TODO: This means potentially setting this twice, first time few lines above
log.Debug(fmt.Sprintf("[%s] Received status message OK", peerID), "name", peer.Name())
if err := runPeer(