]> Sergey Matveev's repositories - btrtrc.git/blobdiff - connection.go
Use stringer to generate peer_protocol.MessageType strings
[btrtrc.git] / connection.go
index 16888aa0ca104f96721bca889ffb2b319aededf8..947adc5ffbbbb37a4dbdb96a77157e25cf2ca0d3 100644 (file)
@@ -252,7 +252,7 @@ func (cn *connection) PeerHasPiece(piece int) bool {
 
 // Writes a message into the write buffer.
 func (cn *connection) Post(msg pp.Message) {
-       messageTypesPosted.Add(strconv.FormatInt(int64(msg.Type), 10), 1)
+       messageTypesPosted.Add(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.).
@@ -808,7 +808,7 @@ func (c *connection) requestPendingMetadata() {
 }
 
 func (cn *connection) wroteMsg(msg *pp.Message) {
-       messageTypesSent.Add(strconv.FormatInt(int64(msg.Type), 10), 1)
+       messageTypesSent.Add(msg.Type.String(), 1)
        cn.stats.wroteMsg(msg)
        cn.t.stats.wroteMsg(msg)
 }
@@ -945,7 +945,7 @@ func (c *connection) mainReadLoop() error {
                        receivedKeepalives.Add(1)
                        continue
                }
-               messageTypesReceived.Add(strconv.FormatInt(int64(msg.Type), 10), 1)
+               messageTypesReceived.Add(msg.Type.String(), 1)
                if msg.Type.FastExtension() && !c.fastEnabled() {
                        return fmt.Errorf("received fast extension message (type=%v) but extension is disabled", msg.Type)
                }