]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Wasn't recording posted message stats
authorMatt Joiner <anacrolix@gmail.com>
Sat, 3 Feb 2018 04:29:06 +0000 (15:29 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Sat, 3 Feb 2018 04:29:06 +0000 (15:29 +1100)
connection.go

index 5c1a6c8489cb3986c27a534f6fa2f5a2132c8f81..1e7ef968a53348feac84479f41433d3a8bc2d3c1 100644 (file)
@@ -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()
 }