]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Show metadata state in status output
authorMatt Joiner <anacrolix@gmail.com>
Wed, 25 Mar 2015 04:50:31 +0000 (15:50 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 25 Mar 2015 04:50:31 +0000 (15:50 +1100)
This is help verify the cause for an occasional stall obtaining metadata from peers.

torrent.go

index 0f302c72d4ae270cf243504519f07f0ce8fabad9..056ad80fdb1e09fa983835f8dbb42890545a872a 100644 (file)
@@ -467,6 +467,18 @@ func (t *torrent) pieceStatusCharSequences() (ret []PieceStatusCharSequence) {
 
 func (t *torrent) writeStatus(w io.Writer) {
        fmt.Fprintf(w, "Infohash: %x\n", t.InfoHash)
+       fmt.Fprintf(w, "Metadata length: %d\n", t.metadataSize())
+       fmt.Fprintf(w, "Metadata have: ")
+       for _, h := range t.metadataHave {
+               fmt.Fprintf(w, "%c", func() rune {
+                       if h {
+                               return 'H'
+                       } else {
+                               return '.'
+                       }
+               }())
+       }
+       fmt.Fprintln(w)
        fmt.Fprintf(w, "Piece length: %s\n", func() string {
                if t.haveInfo() {
                        return fmt.Sprint(t.usualPieceSize())