]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Upgrade Torrent.GotInfo
authorMatt Joiner <anacrolix@gmail.com>
Thu, 7 Oct 2021 00:50:30 +0000 (11:50 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 7 Oct 2021 00:50:30 +0000 (11:50 +1100)
t.go

diff --git a/t.go b/t.go
index 51c76d5b0423fc3d59783630a15693780d00821e..042a5262560a33375fd052c73bdc015f8a331067 100644 (file)
--- a/t.go
+++ b/t.go
@@ -4,6 +4,7 @@ import (
        "strconv"
        "strings"
 
+       "github.com/anacrolix/chansync/events"
        "github.com/anacrolix/missinggo/pubsub"
        "github.com/anacrolix/sync"
 
@@ -16,12 +17,8 @@ func (t *Torrent) InfoHash() metainfo.Hash {
 }
 
 // Returns a channel that is closed when the info (.Info()) for the torrent has become available.
-func (t *Torrent) GotInfo() (ret <-chan struct{}) {
-       // TODO: We shouldn't need to lock to take a channel here, if the event is only ever set.
-       t.nameMu.RLock()
-       ret = t.gotMetainfoC
-       t.nameMu.RUnlock()
-       return
+func (t *Torrent) GotInfo() events.Done {
+       return t.gotMetainfoC
 }
 
 // Returns the metainfo info dictionary, or nil if it's not yet available.