Skip to content

Commit

Permalink
Fix neighbor log message
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Dec 14, 2023
1 parent 4fbaf8f commit 751c9dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/network/p2p/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func (m *Manager) addNeighbor(peer *network.Peer, ps *PacketsStream) error {
}
nbr.readLoop()
nbr.writeLoop()
nbr.logger.LogInfo("Connection established")
nbr.logger.LogInfo("Connection established to %s")
m.Events.NeighborAdded.Trigger(nbr)

return nil
Expand Down
9 changes: 6 additions & 3 deletions pkg/network/p2p/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package p2p

import (
"context"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -52,16 +51,20 @@ type Neighbor struct {
func NewNeighbor(parentLogger log.Logger, p *network.Peer, stream *PacketsStream, packetReceivedCallback PacketReceivedFunc, disconnectedCallback NeighborDisconnectedFunc) *Neighbor {
ctx, cancel := context.WithCancel(context.Background())

return &Neighbor{
n := &Neighbor{
Peer: p,
logger: parentLogger.NewChildLogger(fmt.Sprintf("peers.%s", p.ID.String()[:6])),
logger: parentLogger.NewChildLogger("peer", true),
packetReceivedFunc: packetReceivedCallback,
disconnectedFunc: disconnectedCallback,
loopCtx: ctx,
loopCtxCancel: cancel,
stream: stream,
sendQueue: make(chan *queuedPacket, NeighborsSendQueueSize),
}

n.logger.LogInfo("created", "ID", n.ID)

return n
}

func (n *Neighbor) Enqueue(packet proto.Message, protocolID protocol.ID) {
Expand Down

0 comments on commit 751c9dc

Please sign in to comment.