allow ConnStats being marsheled to json

This commit is contained in:
boypt 2019-05-23 13:58:17 +08:00 committed by Matt Joiner
parent d2400968fc
commit 25d76e0449
1 changed files with 5 additions and 0 deletions

View 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 {