]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Check piece completion state as soon as a handle to torrent data is obtained from...
authorMatt Joiner <anacrolix@gmail.com>
Thu, 24 Dec 2015 14:33:10 +0000 (01:33 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 24 Dec 2015 14:33:10 +0000 (01:33 +1100)
This helps flex the new concurrency implementation in the piece store http backend

data/pieceStore/store.go

index 822ccef5457567412ebc134c3d04faf135853f9a..bb5e31d91b524fbbfdde99b08606f3473377a0f0 100644 (file)
@@ -40,8 +40,12 @@ func (me *store) incompletePiecePath(p metainfo.Piece) string {
                hex.EncodeToString(p.Hash()))
 }
 
-func (me *store) OpenTorrentData(info *metainfo.Info) *data {
-       return &data{info, me}
+func (me *store) OpenTorrentData(info *metainfo.Info) (ret *data) {
+       ret = &data{info, me}
+       for i := range iter.N(info.NumPieces()) {
+               go ret.PieceComplete(i)
+       }
+       return
 }
 
 func New(db dataBackend.I) *store {