Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default case #341

Merged
merged 3 commits into from
Nov 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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