From e1ea10fa2d2dd02dd462e524827f1bf0ad7bde6c Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 3 Feb 2018 15:29:06 +1100 Subject: [PATCH] Wasn't recording posted message stats --- connection.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/connection.go b/connection.go index 5c1a6c84..1e7ef968 100644 --- a/connection.go +++ b/connection.go @@ -243,9 +243,16 @@ func (cn *connection) PeerHasPiece(piece int) bool { return cn.peerSentHaveAll || cn.peerPieces.Contains(piece) } +// Writes a message into the write buffer. func (cn *connection) Post(msg pp.Message) { messageTypesPosted.Add(strconv.FormatInt(int64(msg.Type), 10), 1) + // We don't need to track bytes here because a connection.w Writer wrapper + // takes care of that (although there's some delay between us recording + // the message, and the connection writer flushing it out.). cn.writeBuffer.Write(msg.MustMarshalBinary()) + // Last I checked only Piece messages affect stats, and we don't post + // those. + cn.wroteMsg(&msg) cn.tickleWriter() } -- 2.50.0