forked from LBRYCommunity/lbry-sdk
fix blob history and callback from _download_succeeded
previously _download_succeeded did not block on blob_completed, presumably because even longer ago it did not block on a deriving immediate_announce call and thus took a long time to return
This commit is contained in:
parent
250855d45d
commit
9de4657a4d
2 changed files with 6 additions and 5 deletions
|
@ -516,8 +516,6 @@ class DownloadRequest(RequestHelper):
|
||||||
def _pay_or_cancel_payment(self, arg, reserved_points, blob):
|
def _pay_or_cancel_payment(self, arg, reserved_points, blob):
|
||||||
if self._can_pay_peer(blob, arg):
|
if self._can_pay_peer(blob, arg):
|
||||||
self._pay_peer(blob.length, reserved_points)
|
self._pay_peer(blob.length, reserved_points)
|
||||||
d = self.requestor.blob_manager.add_blob_to_download_history(
|
|
||||||
str(blob), str(self.peer.host), float(self.protocol_prices[self.protocol]))
|
|
||||||
else:
|
else:
|
||||||
self._cancel_points(reserved_points)
|
self._cancel_points(reserved_points)
|
||||||
return arg
|
return arg
|
||||||
|
@ -567,8 +565,11 @@ class DownloadRequest(RequestHelper):
|
||||||
self.peer.update_stats('blobs_downloaded', 1)
|
self.peer.update_stats('blobs_downloaded', 1)
|
||||||
self.peer.update_score(5.0)
|
self.peer.update_score(5.0)
|
||||||
should_announce = blob.blob_hash == self.head_blob_hash
|
should_announce = blob.blob_hash == self.head_blob_hash
|
||||||
self.requestor.blob_manager.blob_completed(blob, should_announce=should_announce)
|
d = self.requestor.blob_manager.blob_completed(blob, should_announce=should_announce)
|
||||||
return arg
|
d.addCallback(lambda _: self.requestor.blob_manager.add_blob_to_download_history(
|
||||||
|
blob.blob_hash, self.peer.host, self.protocol_prices[self.protocol]))
|
||||||
|
d.addCallback(lambda _: arg)
|
||||||
|
return d
|
||||||
|
|
||||||
def _download_failed(self, reason):
|
def _download_failed(self, reason):
|
||||||
if not reason.check(DownloadCanceledError, PriceDisagreementError):
|
if not reason.check(DownloadCanceledError, PriceDisagreementError):
|
||||||
|
|
|
@ -162,7 +162,7 @@ class BlobRequestHandler(object):
|
||||||
|
|
||||||
def record_transaction(self, blob):
|
def record_transaction(self, blob):
|
||||||
d = self.blob_manager.add_blob_to_upload_history(
|
d = self.blob_manager.add_blob_to_upload_history(
|
||||||
str(blob), self.peer.host, self.blob_data_payment_rate)
|
blob.blob_hash, self.peer.host, self.blob_data_payment_rate)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _reply_to_send_request(self, response, incoming):
|
def _reply_to_send_request(self, response, incoming):
|
||||||
|
|
Loading…
Reference in a new issue