From: Matt Joiner Date: Wed, 15 Apr 2020 08:09:15 +0000 (+1000) Subject: Count outgoing extended messages by extension protocol X-Git-Tag: v1.16.0~83 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=3d87c2076636fd919eb5c3aa10d3b84139fe35e5;p=btrtrc.git Count outgoing extended messages by extension protocol --- diff --git a/peerconn.go b/peerconn.go index a5153fbf..1be12891 100644 --- a/peerconn.go +++ b/peerconn.go @@ -863,6 +863,14 @@ func (c *PeerConn) requestPendingMetadata() { func (cn *PeerConn) wroteMsg(msg *pp.Message) { torrent.Add(fmt.Sprintf("messages written of type %s", msg.Type.String()), 1) + if msg.Type == pp.Extended { + for name, id := range cn.PeerExtensionIDs { + if id != msg.ExtendedID { + continue + } + torrent.Add(fmt.Sprintf("Extended messages written for protocol %q", name), 1) + } + } cn.allStats(func(cs *ConnStats) { cs.wroteMsg(msg) }) }