From: Matt Joiner Date: Thu, 24 Dec 2015 14:33:10 +0000 (+1100) Subject: Check piece completion state as soon as a handle to torrent data is obtained from... X-Git-Tag: v1.0.0~952 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=a0f374ce8d17057003fc1ebd958c9a8ee59a3358;p=btrtrc.git Check piece completion state as soon as a handle to torrent data is obtained from a piece store This helps flex the new concurrency implementation in the piece store http backend --- diff --git a/data/pieceStore/store.go b/data/pieceStore/store.go index 822ccef5..bb5e31d9 100644 --- a/data/pieceStore/store.go +++ b/data/pieceStore/store.go @@ -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 {