allow ConnStats being marsheled to json
This commit is contained in:
parent
d2400968fc
commit
25d76e0449
|
@ -5,6 +5,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
pp "github.com/anacrolix/torrent/peer_protocol"
|
pp "github.com/anacrolix/torrent/peer_protocol"
|
||||||
)
|
)
|
||||||
|
@ -65,6 +66,10 @@ func (me *Count) String() string {
|
||||||
return fmt.Sprintf("%v", me.Int64())
|
return fmt.Sprintf("%v", me.Int64())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (me *Count) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(me.n)
|
||||||
|
}
|
||||||
|
|
||||||
func (cs *ConnStats) wroteMsg(msg *pp.Message) {
|
func (cs *ConnStats) wroteMsg(msg *pp.Message) {
|
||||||
// TODO: Track messages and not just chunks.
|
// TODO: Track messages and not just chunks.
|
||||||
switch msg.Type {
|
switch msg.Type {
|
||||||
|
|
Loading…
Reference in New Issue