// Writes a message into the write buffer.
func (cn *connection) Post(msg pp.Message) {
- messageTypesPosted.Add(msg.Type.String(), 1)
+ torrent.Add(fmt.Sprintf("messages posted of type %s", msg.Type.String()), 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.fillWriteBuffer(func(msg pp.Message) bool {
cn.wroteMsg(&msg)
cn.writeBuffer.Write(msg.MustMarshalBinary())
- return cn.writeBuffer.Len() < 1<<16
+ torrent.Add(fmt.Sprintf("messages filled of type %s", msg.Type.String()), 1)
+ return cn.writeBuffer.Len() < 1<<16 // 64KiB
})
}
if cn.writeBuffer.Len() == 0 && time.Since(lastWrite) >= keepAliveTimeout {
}
func (cn *connection) wroteMsg(msg *pp.Message) {
- messageTypesSent.Add(msg.Type.String(), 1)
+ torrent.Add(fmt.Sprintf("messages written of type %s", msg.Type.String()), 1)
cn.allStats(func(cs *ConnStats) { cs.wroteMsg(msg) })
}
requestedChunkLengths = expvar.NewMap("requestedChunkLengths")
messageTypesReceived = expvar.NewMap("messageTypesReceived")
- messageTypesSent = expvar.NewMap("messageTypesSent")
- messageTypesPosted = expvar.NewMap("messageTypesPosted")
// Track the effectiveness of Torrent.connPieceInclinationPool.
pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")