From: Matt Joiner Date: Sat, 3 Feb 2018 04:29:06 +0000 (+1100) Subject: Wasn't recording posted message stats X-Git-Tag: v1.0.0~211 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=e1ea10fa2d2dd02dd462e524827f1bf0ad7bde6c;p=btrtrc.git Wasn't recording posted message stats --- 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() }