Exemple #1
0
def download_sd_blob(session, blob_hash, payment_rate_manager, timeout=None):
    """
    Downloads a single blob from the network

    @param session:

    @param blob_hash:

    @param payment_rate_manager:

    @return: An object of type HashBlob
    """

    downloader = StandaloneBlobDownloader(blob_hash, session.blob_manager,
                                          session.peer_finder,
                                          session.rate_limiter,
                                          payment_rate_manager, session.wallet,
                                          timeout)
    sd_blob = yield downloader.download()
    sd_reader = BlobStreamDescriptorReader(sd_blob)
    sd_info = yield sd_reader.get_info()
    try:
        validate_descriptor(sd_info)
    except InvalidStreamDescriptorError as err:
        yield session.blob_manager.delete_blobs([blob_hash])
        raise err
    raw_sd = yield sd_reader._get_raw_data()
    yield session.blob_manager.storage.add_known_blob(blob_hash, len(raw_sd))
    yield save_sd_info(session.blob_manager, sd_blob.blob_hash, sd_info)
    defer.returnValue(sd_blob)
Exemple #2
0
 def download_blob(blob_hash):
     prm = self.session.payment_rate_manager
     downloader = StandaloneBlobDownloader(blob_hash,
                                           self.session.blob_manager,
                                           peer_finder, rate_limiter,
                                           prm, wallet)
     d = downloader.download()
     return d
Exemple #3
0
 def download_sd_file_from_hash(self, sd_hash):
     downloader = StandaloneBlobDownloader(sd_hash,
                                           self.session.blob_manager,
                                           self.session.peer_finder,
                                           self.session.rate_limiter,
                                           self.session.wallet)
     d = downloader.download()
     return d
Exemple #4
0
def download_sd_blob(session, blob_hash, payment_rate_manager):
    """
    Downloads a single blob from the network

    @param session:

    @param blob_hash:

    @param payment_rate_manager:

    @return: An object of type HashBlob
    """
    downloader = StandaloneBlobDownloader(blob_hash, session.blob_manager, session.peer_finder,
                                          session.rate_limiter, payment_rate_manager, session.wallet)
    return downloader.download()
Exemple #5
0
    def download_blob_from_peer(self, peer, timeout, blob_hash, blob_manager):
        log.debug("Try to download %s from %s", blob_hash, peer.host)
        blob_manager = blob_manager
        blob = BlobCallback(blob_manager.blob_dir, blob_hash, timeout)
        download_manager = SingleBlobDownloadManager(blob)
        peer_finder = SinglePeerFinder(peer)
        requester = BlobRequester(blob_manager, peer_finder,
                                  self._payment_rate_manager, self._wallet,
                                  download_manager)
        downloader = StandaloneBlobDownloader(blob_hash,
                                              blob_manager,
                                              peer_finder,
                                              self._rate_limiter,
                                              self._payment_rate_manager,
                                              self._wallet,
                                              timeout=timeout)
        info_exchanger = self._wallet.get_info_exchanger()
        connection_manager = ConnectionManager(downloader, self._rate_limiter,
                                               [requester], [info_exchanger])
        connection_manager.start()

        result = yield blob.callback
        if not result:
            log.debug("Failed to downloaded %s from %s", blob_hash[:16],
                      peer.host)
            yield connection_manager.stop()
        defer.returnValue(result)
Exemple #6
0
def download_sd_blob(session, blob_hash, payment_rate_manager):
    """
    Downloads a single blob from the network

    @param session:

    @param blob_hash:

    @param payment_rate_manager:

    @return: An object of type HashBlob
    """
    downloader = StandaloneBlobDownloader(blob_hash, session.blob_manager,
                                          session.peer_finder,
                                          session.rate_limiter,
                                          payment_rate_manager, session.wallet)
    return downloader.download()
Exemple #7
0
 def download_sd_file_from_hash(self, sd_hash):
     downloader = StandaloneBlobDownloader(sd_hash, self.session.blob_manager,
                                           self.session.peer_finder, self.session.rate_limiter,
                                           self.session.wallet)
     d = downloader.download()
     return d
Exemple #8
0
 def download_blob(blob_hash):
     prm = PaymentRateManager(self.session.base_payment_rate_manager)
     downloader = StandaloneBlobDownloader(blob_hash, self.session.blob_manager, peer_finder,
                                           rate_limiter, prm, wallet)
     d = downloader.download()
     return d