Skip to content

Commit

Permalink
Remove default case (#341)
Browse files Browse the repository at this point in the history
* Remove `default` case

* fix lint error: S1000: should use a simple channel send/receive instead of `select` with a single case (gosimple)

* (fix) Remove block comment and add a comment
  • Loading branch information
tnasu authored Nov 17, 2021
1 parent 530dbec commit 88b765b
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions p2p/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,19 +399,8 @@ func createMConnection(
// because msgBytes is on socket receive buffer yet so reactor can read it concurrently
copied := make([]byte, len(msgBytes))
copy(copied, msgBytes)
select {
case ch <- &BufferedMsg{
ChID: chID,
Peer: p,
Msg: copied}:
default:
// if the channel is full, we abandon this message
// Should check `config.Config.XxxBufSize`
p.Logger.Error("Lost the message since BaseReactor.recvMsgBuf is full",
"reactor", reactor,
"msgBytes.len", len(msgBytes), "msgBytes", fmt.Sprintf("%X", msgBytes))
p.metrics.NumAbandonedPeerMsgs.With(labels...).Add(1)
}
// if the channel is full, we are blocking a message until it can send into the channel
ch <- &BufferedMsg{ChID: chID, Peer: p, Msg: copied}
} else {
reactor.Receive(chID, p, msgBytes)
}
Expand Down

0 comments on commit 88b765b

Please sign in to comment.