internal TorrentDownloadManager(PeerId localPeerId,
                                        IMainLoop mainLoop,
                                        IApplicationProtocol <PeerConnection> applicationProtocol,
                                        ITracker tracker,
                                        Metainfo description)
        {
            this.localPeerId    = localPeerId;
            this.mainLoop       = mainLoop;
            ApplicationProtocol = applicationProtocol;
            Description         = description;
            Tracker             = tracker;
            State                     = DownloadState.Pending;
            Downloaded                = 0;
            DownloadRateMeasurer      = new RateMeasurer();
            UploadRateMeasurer        = new RateMeasurer();
            progress                  = new Progress <StatusUpdate>();
            progress.ProgressChanged += ProgressChanged;

            pipeline = new PipelineBuilder()
                       .AddStage <VerifyDownloadedPiecesStage>()
                       .AddStage <DownloadPiecesStage>()
                       .Build();

            stageInterrupt = new StageInterrupt();
        }
예제 #2
0
        /// <summary>
        /// Creates a bandwidth limiter.
        /// </summary>
        /// <param name="rateMeasurer">The rate measurer to use.</param>
        /// <param name="rateLimit">The maximum rate before limiting.</param>
        public BandwidthLimiter(RateMeasurer rateMeasurer, long rateLimit)
        {
            if (rateMeasurer == null)
            {
                throw new ArgumentNullException("rateMeasurer");
            }

            this.rateMeasurer = rateMeasurer;
            this.rateLimit    = rateLimit;
        }
예제 #3
0
        public PipelineRunner(ILogger <PipelineRunner> logger,
                              PeerId localPeerId,
                              IMainLoop mainLoop,
                              IApplicationProtocol applicationProtocol,
                              ITracker tracker,
                              IServiceProvider parentContainer,
                              IPipelineFactory pipelineFactory)
        {
            _logger             = logger;
            _localPeerId        = localPeerId;
            _mainLoop           = mainLoop;
            ApplicationProtocol = applicationProtocol;
            Description         = applicationProtocol.Metainfo;
            _parentContainer    = parentContainer;
            _pipelineFactory    = pipelineFactory;
            Tracker             = tracker;
            State = DownloadState.Pending;
            DownloadRateMeasurer       = new RateMeasurer();
            UploadRateMeasurer         = new RateMeasurer();
            _progress                  = new Progress <StatusUpdate>();
            _progress.ProgressChanged += ProgressChanged;

            _stageInterrupt = new StageInterrupt();
        }