2017-09-25 18:12:40 +02:00
|
|
|
from lbrynet.blob.blob_file import MAX_BLOB_SIZE
|
2015-08-20 17:27:15 +02:00
|
|
|
|
2018-01-31 02:16:25 +01:00
|
|
|
|
2018-07-22 00:34:59 +02:00
|
|
|
class ClientRequest:
|
2015-08-20 17:27:15 +02:00
|
|
|
def __init__(self, request_dict, response_identifier=None):
|
|
|
|
self.request_dict = request_dict
|
|
|
|
self.response_identifier = response_identifier
|
|
|
|
|
|
|
|
|
|
|
|
class ClientPaidRequest(ClientRequest):
|
|
|
|
def __init__(self, request_dict, response_identifier, max_pay_units):
|
2018-07-22 00:34:59 +02:00
|
|
|
super().__init__(request_dict, response_identifier)
|
2015-08-20 17:27:15 +02:00
|
|
|
self.max_pay_units = max_pay_units
|
|
|
|
|
|
|
|
|
|
|
|
class ClientBlobRequest(ClientPaidRequest):
|
|
|
|
def __init__(self, request_dict, response_identifier, write_func, finished_deferred,
|
|
|
|
cancel_func, blob):
|
|
|
|
if blob.length is None:
|
2017-09-25 18:12:40 +02:00
|
|
|
max_pay_units = MAX_BLOB_SIZE
|
2015-08-20 17:27:15 +02:00
|
|
|
else:
|
|
|
|
max_pay_units = blob.length
|
2018-07-22 00:34:59 +02:00
|
|
|
super().__init__(request_dict, response_identifier, max_pay_units)
|
2015-08-20 17:27:15 +02:00
|
|
|
self.write = write_func
|
|
|
|
self.finished_deferred = finished_deferred
|
|
|
|
self.cancel = cancel_func
|
2016-12-14 00:16:12 +01:00
|
|
|
self.blob = blob
|