]> Sergey Matveev's repositories - btrtrc.git/commitdiff
allow ConnStats being marsheled to json
authorboypt <1033514+boypt@users.noreply.github.com>
Thu, 23 May 2019 05:58:17 +0000 (13:58 +0800)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 29 May 2019 05:05:31 +0000 (15:05 +1000)
conn_stats.go

index a691fb342f24bbe30fac479840097c8901e5dd5c..06ec23f2cb6eed31c149f65629180bb673bad82e 100644 (file)
@@ -5,6 +5,7 @@ import (
        "io"
        "reflect"
        "sync/atomic"
+       "encoding/json"
 
        pp "github.com/anacrolix/torrent/peer_protocol"
 )
@@ -65,6 +66,10 @@ func (me *Count) String() string {
        return fmt.Sprintf("%v", me.Int64())
 }
 
+func (me *Count) MarshalJSON() ([]byte, error) {
+       return json.Marshal(me.n)
+}
+
 func (cs *ConnStats) wroteMsg(msg *pp.Message) {
        // TODO: Track messages and not just chunks.
        switch msg.Type {