From 25d76e04495c333df1241c8588732c5be4799fe8 Mon Sep 17 00:00:00 2001 From: boypt <1033514+boypt@users.noreply.github.com> Date: Thu, 23 May 2019 13:58:17 +0800 Subject: [PATCH] allow ConnStats being marsheled to json --- conn_stats.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conn_stats.go b/conn_stats.go index a691fb34..06ec23f2 100644 --- a/conn_stats.go +++ b/conn_stats.go @@ -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 {