]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add more information I've needed to the status page
authorMatt Joiner <anacrolix@gmail.com>
Wed, 16 Jul 2014 07:07:28 +0000 (17:07 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 16 Jul 2014 07:07:28 +0000 (17:07 +1000)
client.go
connection.go
dht/dht.go
torrent.go

index 9808a2aa8ca91954dceded26b5eb19a55e17bd5f..6362275e46715074de55102b1d397440ab1cd8e8 100644 (file)
--- a/client.go
+++ b/client.go
@@ -120,6 +120,9 @@ type Client struct {
 func (cl *Client) WriteStatus(w io.Writer) {
        cl.mu.Lock()
        defer cl.mu.Unlock()
+       fmt.Fprintf(w, "Half open: %d\n", cl.halfOpen)
+       fmt.Fprintf(w, "DHT nodes: %d\n", cl.DHT.NumNodes())
+       fmt.Fprintln(w)
        for _, t := range cl.torrents {
                fmt.Fprintf(w, "%s: %f%%\n", t.Name(), func() float32 {
                        if !t.haveInfo() {
index 2832e0cfcc54e379791bb189896e24cca0406a28..f07473757ec262149d6fb9f72784660515fa0c92 100644 (file)
@@ -69,7 +69,7 @@ func (cn *connection) piecesPeerHasCount() (count int) {
 }
 
 func (cn *connection) WriteStatus(w io.Writer) {
-       fmt.Fprintf(w, "%q: %s-%s: %s completed: ", cn.PeerId, cn.Socket.LocalAddr(), cn.Socket.RemoteAddr(), cn.completedString())
+       fmt.Fprintf(w, "%q: %s-%s: %s completed, reqs: %d-%d, flags: ", cn.PeerId, cn.Socket.LocalAddr(), cn.Socket.RemoteAddr(), cn.completedString(), len(cn.Requests), len(cn.PeerRequests))
        c := func(b byte) {
                fmt.Fprintf(w, "%c", b)
        }
index 16e4a20b3b4335faf931d1aee442324a408688b7..257945418344a050510c571fedf7a9ba6203337a 100644 (file)
@@ -679,6 +679,12 @@ func (s *Server) Bootstrap() (err error) {
        return
 }
 
+func (s *Server) NumNodes() int {
+       s.mu.Lock()
+       defer s.mu.Unlock()
+       return len(s.nodes)
+}
+
 func (s *Server) Nodes() (nis []NodeInfo) {
        s.mu.Lock()
        defer s.mu.Unlock()
index 8a2124576f7a1c954d91fc3b574c4d99389d9e5b..a96c48d6273b957850bb8457acb70b21b227fb6e 100644 (file)
@@ -206,6 +206,7 @@ func (t *torrent) WriteStatus(w io.Writer) {
                        fmt.Fprintf(w, "\t%v\n", e.Value)
                }
        }
+       fmt.Fprintf(w, "Pending peers: %d\n", len(t.Peers))
        for _, c := range t.Conns {
                c.WriteStatus(w)
        }