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
This commit is contained in:
Matt Joiner 2015-12-25 01:33:10 +11:00
parent 08f8d7bd19
commit a0f374ce8d
1 changed files with 6 additions and 2 deletions

View 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 {