]> Sergey Matveev's repositories - btrtrc.git/blobdiff - torrent.go
Implement reading piece hashes from peers
[btrtrc.git] / torrent.go
index 8a403e16aba5571fab7d2cd3e22259b69da7d3b2..e7b579b3c0e89a38d4bc5fc72cf533b054c56f82 100644 (file)
@@ -2006,8 +2006,7 @@ func (t *Torrent) AnnounceToDht(s DhtServer) (done <-chan struct{}, stop func(),
        go func() {
                defer stop()
                defer close(_done)
-               // Won't this race?
-               err = eg.Wait()
+               eg.Wait()
        }()
        return
 }
@@ -3118,3 +3117,12 @@ func (t *Torrent) eachShortInfohash(each func(short [20]byte)) {
                each(*t.infoHashV2.Value.ToShort())
        }
 }
+
+func (t *Torrent) getFileByPiecesRoot(hash [32]byte) *File {
+       for _, f := range *t.files {
+               if f.piecesRoot.Unwrap() == hash {
+                       return f
+               }
+       }
+       return nil
+}