Skip to content

Commit

Permalink
Improve net debug
Browse files Browse the repository at this point in the history
  • Loading branch information
lrettig committed Mar 21, 2021
1 parent 6dcc21c commit 73306ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions p2p/net/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ func (c *FormattedConnection) sendListener() {
for {
select {
case m := <-c.messages:
c.logger.With().Debug("sending outgoing message",
log.String("requestID", m.reqID))

//todo: we are hiding the error here...
if err := c.SendSock(m.payload); err != nil {
c.logger.With().Error("cannot send message to peer",
Expand All @@ -249,6 +252,7 @@ func (c *FormattedConnection) Send(ctx context.Context, m []byte) error {
// try to extract a requestID from the context
reqID, _ := log.ExtractRequestID(ctx)

c.logger.WithContext(ctx).Debug("enqueuing outgoing message")
c.messages <- msgToSend{m, reqID}
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions p2p/net/msgcon.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ func (c *MsgConnection) sendListener() {
for {
select {
case m := <-c.messages:
c.logger.With().Debug("sending outgoing message",
log.String("requestID", m.reqID))

//todo: we are hiding the error here...
if err := c.SendSock(m.payload); err != nil {
log.With().Error("cannot send message to peer",
Expand All @@ -172,6 +175,7 @@ func (c *MsgConnection) Send(ctx context.Context, m []byte) error {
// try to extract a requestID from the context
reqID, _ := log.ExtractRequestID(ctx)

c.logger.WithContext(ctx).Debug("enqueuing outgoing message")
c.messages <- msgToSend{m, reqID}
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions p2p/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,8 @@ func (s *Switch) sendMessageImpl(ctx context.Context, peerPubKey p2pcrypto.Publi
}

conn, err = s.cPool.GetConnectionIfExists(peerPubKey)

if err != nil {
return errors.New("this peer isn't a neighbor or connection lost")
return fmt.Errorf("peer not a neighbor or connection lost: %v", err)
}

session := conn.Session()
Expand Down

0 comments on commit 73306ec

Please sign in to comment.