server: fix logging of pubkey

This commit is contained in:
Oliver Gugger 2024-05-23 13:11:38 +02:00
parent c5973aa136
commit 1167e9b6dd
No known key found for this signature in database
GPG key ID: 8E4256593F177720

View file

@ -4113,11 +4113,12 @@ func (s *server) peerInitializer(p *peer.Brontide) {
s.wg.Add(1) s.wg.Add(1)
go s.peerTerminationWatcher(p, ready) go s.peerTerminationWatcher(p, ready)
pubBytes := p.IdentityKey().SerializeCompressed()
// Start the peer! If an error occurs, we Disconnect the peer, which // Start the peer! If an error occurs, we Disconnect the peer, which
// will unblock the peerTerminationWatcher. // will unblock the peerTerminationWatcher.
if err := p.Start(); err != nil { if err := p.Start(); err != nil {
srvrLog.Warnf("Starting peer=%v got error: %v", srvrLog.Warnf("Starting peer=%x got error: %v", pubBytes, err)
p.IdentityKey(), err)
p.Disconnect(fmt.Errorf("unable to start peer: %w", err)) p.Disconnect(fmt.Errorf("unable to start peer: %w", err))
return return
@ -4127,13 +4128,15 @@ func (s *server) peerInitializer(p *peer.Brontide) {
// was successful, and to begin watching the peer's wait group. // was successful, and to begin watching the peer's wait group.
close(ready) close(ready)
pubStr := string(p.IdentityKey().SerializeCompressed())
s.mu.Lock() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
// Check if there are listeners waiting for this peer to come online. // Check if there are listeners waiting for this peer to come online.
srvrLog.Debugf("Notifying that peer %v is online", p) srvrLog.Debugf("Notifying that peer %v is online", p)
// TODO(guggero): Do a proper conversion to a string everywhere, or use
// route.Vertex as the key type of peerConnectedListeners.
pubStr := string(pubBytes)
for _, peerChan := range s.peerConnectedListeners[pubStr] { for _, peerChan := range s.peerConnectedListeners[pubStr] {
select { select {
case peerChan <- p: case peerChan <- p: