Esempio n. 1
0
        public void LoadFastResume(FastResume data)
        {
            Check.Data(data);
            CheckMetadata();
            if (State != TorrentState.Stopped)
            {
                throw new InvalidOperationException("Can only load FastResume when the torrent is stopped");
            }
            if (InfoHash != data.Infohash || _torrent.Pieces.Count != data.Bitfield.Length)
            {
                throw new ArgumentException("The fast resume data does not match this torrent", "fastResumeData");
            }

            _bitfield.From(data.Bitfield);
            for (var i = 0; i < _torrent.Pieces.Count; i++)
            {
                RaisePieceHashed(new PieceHashedEventArgs(this, i, _bitfield[i]));
            }

            _hashChecked = true;
        }