Refactor log statement for peer status trace

Move the peer status trace log inside a conditional block to ensure it only logs when the peer status is not connected. This refactor prevents unnecessary logging and streamlines the execution trace.
This commit is contained in:
bcmmbaga 2024-07-26 11:51:41 +03:00
parent 5d81e7aa0c
commit f2f5609c6e
No known key found for this signature in database
GPG Key ID: 7249A19D20613553

View File

@ -309,9 +309,11 @@ func (s *SqlStore) SavePeerStatus(accountID, peerID string, peerStatus nbpeer.Pe
var peerCopy nbpeer.Peer
peerCopy.Status = &peerStatus
log.WithContext(context.Background()).Tracef("saving peer: %s with false status. PeerCopy %v, Arg: %v, Trace: %s",
peerID, peerCopy.Status.Connected, peerStatus.Connected,
debug.Stack())
if !peerStatus.Connected {
log.WithContext(context.Background()).Tracef("saving peer: %s with false status. PeerCopy %v, Arg: %v, Trace: %s",
peerID, peerCopy.Status.Connected, peerStatus.Connected,
debug.Stack())
}
fieldsToUpdate := []string{
"peer_status_last_seen", "peer_status_connected",