rename is_validated() to get_is_verified() to distinguish from verified property
This commit is contained in:
parent
dbb658adec
commit
6cbe86d057
11 changed files with 26 additions and 25 deletions
|
@ -141,8 +141,8 @@ class BlobFile(object):
|
|||
def get_length(self):
|
||||
return self.length
|
||||
|
||||
def is_validated(self):
|
||||
return bool(self._verified)
|
||||
def get_is_verified(self):
|
||||
return self.verified
|
||||
|
||||
def is_downloading(self):
|
||||
if self.writers:
|
||||
|
|
|
@ -465,7 +465,7 @@ class DownloadRequest(RequestHelper):
|
|||
def find_blob(self, to_download):
|
||||
"""Return the first blob in `to_download` that is successfully opened for write."""
|
||||
for blob in to_download:
|
||||
if blob.is_validated():
|
||||
if blob.get_is_verified():
|
||||
log.debug('Skipping blob %s as its already validated', blob)
|
||||
continue
|
||||
writer, d = blob.open_for_writing(self.peer)
|
||||
|
|
|
@ -64,14 +64,14 @@ class SingleProgressManager(object):
|
|||
|
||||
def stream_position(self):
|
||||
blobs = self.download_manager.blobs
|
||||
if blobs and blobs[0].is_validated():
|
||||
if blobs and blobs[0].get_is_verified():
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def needed_blobs(self):
|
||||
blobs = self.download_manager.blobs
|
||||
assert len(blobs) == 1
|
||||
return [b for b in blobs.itervalues() if not b.is_validated()]
|
||||
return [b for b in blobs.itervalues() if not b.get_is_verified()]
|
||||
|
||||
|
||||
class DummyBlobHandler(object):
|
||||
|
|
|
@ -93,7 +93,7 @@ class FullStreamProgressManager(StreamProgressManager):
|
|||
return (
|
||||
i not in blobs or
|
||||
(
|
||||
not blobs[i].is_validated() and
|
||||
not blobs[i].get_is_verified() and
|
||||
i not in self.provided_blob_nums
|
||||
)
|
||||
)
|
||||
|
@ -112,7 +112,7 @@ class FullStreamProgressManager(StreamProgressManager):
|
|||
blobs = self.download_manager.blobs
|
||||
return [
|
||||
b for n, b in blobs.iteritems()
|
||||
if not b.is_validated() and not n in self.provided_blob_nums
|
||||
if not b.get_is_verified() and not n in self.provided_blob_nums
|
||||
]
|
||||
|
||||
######### internal #########
|
||||
|
@ -145,7 +145,7 @@ class FullStreamProgressManager(StreamProgressManager):
|
|||
|
||||
current_blob_num = self.last_blob_outputted + 1
|
||||
|
||||
if current_blob_num in blobs and blobs[current_blob_num].is_validated():
|
||||
if current_blob_num in blobs and blobs[current_blob_num].get_is_verified():
|
||||
log.debug("Outputting blob %s", str(self.last_blob_outputted + 1))
|
||||
self.provided_blob_nums.append(self.last_blob_outputted + 1)
|
||||
d = self.download_manager.handle_blob(self.last_blob_outputted + 1)
|
||||
|
|
|
@ -143,7 +143,7 @@ class BlobRequestHandler(object):
|
|||
def open_blob_for_reading(self, blob, response):
|
||||
response_fields = {}
|
||||
d = defer.succeed(None)
|
||||
if blob.is_validated():
|
||||
if blob.get_is_verified():
|
||||
read_handle = blob.open_for_reading()
|
||||
if read_handle is not None:
|
||||
self.currently_uploading = blob
|
||||
|
|
|
@ -2457,10 +2457,11 @@ class Daemon(AuthJSONRPCServer):
|
|||
blob_hashes = [blob_hash]
|
||||
elif stream_hash:
|
||||
blobs = yield self.get_blobs_for_stream_hash(stream_hash)
|
||||
blob_hashes = [blob.blob_hash for blob in blobs if blob.is_validated()]
|
||||
blob_hashes = [blob.blob_hash for blob in blobs if blob.get_is_verified()]
|
||||
elif sd_hash:
|
||||
blobs = yield self.get_blobs_for_sd_hash(sd_hash)
|
||||
blob_hashes = [sd_hash] + [blob.blob_hash for blob in blobs if blob.is_validated()]
|
||||
blob_hashes = [sd_hash] + [blob.blob_hash for blob in blobs if
|
||||
blob.get_is_verified()]
|
||||
else:
|
||||
raise Exception('single argument must be specified')
|
||||
yield self.session.blob_manager._immediate_announce(blob_hashes)
|
||||
|
@ -2563,9 +2564,9 @@ class Daemon(AuthJSONRPCServer):
|
|||
blobs = self.session.blob_manager.blobs.itervalues()
|
||||
|
||||
if needed:
|
||||
blobs = [blob for blob in blobs if not blob.is_validated()]
|
||||
blobs = [blob for blob in blobs if not blob.get_is_verified()]
|
||||
if finished:
|
||||
blobs = [blob for blob in blobs if blob.is_validated()]
|
||||
blobs = [blob for blob in blobs if blob.get_is_verified()]
|
||||
|
||||
blob_hashes = [blob.blob_hash for blob in blobs]
|
||||
page_size = page_size or len(blob_hashes)
|
||||
|
|
|
@ -132,7 +132,7 @@ class BlobReflectorClient(Protocol):
|
|||
return self.set_not_uploading()
|
||||
|
||||
def open_blob_for_reading(self, blob):
|
||||
if blob.is_validated():
|
||||
if blob.get_is_verified():
|
||||
read_handle = blob.open_for_reading()
|
||||
if read_handle is not None:
|
||||
log.debug('Getting ready to send %s', blob.blob_hash)
|
||||
|
|
|
@ -116,7 +116,7 @@ class EncryptedFileReflectorClient(Protocol):
|
|||
yield self.blob_manager.get_blob(blob, blob_len)
|
||||
|
||||
dl = defer.DeferredList(list(get_blobs(blobs_in_stream)), consumeErrors=True)
|
||||
dl.addCallback(lambda blobs: [blob for r, blob in blobs if r and blob.is_validated()])
|
||||
dl.addCallback(lambda blobs: [blob for r, blob in blobs if r and blob.get_is_verified()])
|
||||
return dl
|
||||
|
||||
def set_blobs_to_send(self, blobs_to_send):
|
||||
|
@ -253,7 +253,7 @@ class EncryptedFileReflectorClient(Protocol):
|
|||
return self.set_not_uploading()
|
||||
|
||||
def open_blob_for_reading(self, blob):
|
||||
if blob.is_validated():
|
||||
if blob.get_is_verified():
|
||||
read_handle = blob.open_for_reading()
|
||||
if read_handle is not None:
|
||||
log.debug('Getting ready to send %s', blob.blob_hash)
|
||||
|
|
|
@ -231,7 +231,7 @@ class ReflectorServer(Protocol):
|
|||
return d
|
||||
|
||||
def get_descriptor_response(self, sd_blob):
|
||||
if sd_blob.is_validated():
|
||||
if sd_blob.get_is_verified():
|
||||
d = defer.succeed({SEND_SD_BLOB: False})
|
||||
d.addCallback(self.request_needed_blobs, sd_blob)
|
||||
else:
|
||||
|
@ -267,7 +267,7 @@ class ReflectorServer(Protocol):
|
|||
if 'blob_hash' in blob and 'length' in blob:
|
||||
blob_hash, blob_len = blob['blob_hash'], blob['length']
|
||||
d = self.blob_manager.get_blob(blob_hash, blob_len)
|
||||
d.addCallback(lambda blob: blob_hash if not blob.is_validated() else None)
|
||||
d.addCallback(lambda blob: blob_hash if not blob.get_is_verified() else None)
|
||||
yield d
|
||||
|
||||
def handle_blob_request(self, request_dict):
|
||||
|
@ -305,7 +305,7 @@ class ReflectorServer(Protocol):
|
|||
return d
|
||||
|
||||
def get_blob_response(self, blob):
|
||||
if blob.is_validated():
|
||||
if blob.get_is_verified():
|
||||
return defer.succeed({SEND_BLOB: False})
|
||||
else:
|
||||
self.incoming_blob = blob
|
||||
|
|
|
@ -182,7 +182,7 @@ class TestReflector(unittest.TestCase):
|
|||
return factory.finished_deferred
|
||||
|
||||
def verify_blob_completed(blob, blob_size):
|
||||
self.assertTrue(blob.is_validated())
|
||||
self.assertTrue(blob.get_is_verified())
|
||||
self.assertEqual(blob_size, blob.length)
|
||||
return
|
||||
|
||||
|
@ -213,7 +213,7 @@ class TestReflector(unittest.TestCase):
|
|||
return factory.finished_deferred
|
||||
|
||||
def verify_blob_completed(blob, blob_size):
|
||||
self.assertTrue(blob.is_validated())
|
||||
self.assertTrue(blob.get_is_verified())
|
||||
self.assertEqual(blob_size, blob.length)
|
||||
|
||||
d = send_to_server([x[0] for x in self.expected_blobs])
|
||||
|
@ -244,7 +244,7 @@ class TestReflector(unittest.TestCase):
|
|||
return factory.finished_deferred
|
||||
|
||||
def verify_blob_completed(blob, blob_size):
|
||||
self.assertTrue(blob.is_validated())
|
||||
self.assertTrue(blob.get_is_verified())
|
||||
self.assertEqual(blob_size, blob.length)
|
||||
|
||||
d = send_to_server([x[0] for x in self.expected_blobs])
|
||||
|
|
|
@ -53,7 +53,7 @@ class TestBlobRequestHandlerQueries(unittest.TestCase):
|
|||
|
||||
def test_blob_unavailable_when_blob_not_validated(self):
|
||||
blob = mock.Mock()
|
||||
blob.is_validated.return_value = False
|
||||
blob.get_is_verified.return_value = False
|
||||
self.blob_manager.get_blob.return_value = defer.succeed(blob)
|
||||
query = {
|
||||
'blob_data_payment_rate': 1.0,
|
||||
|
@ -68,7 +68,7 @@ class TestBlobRequestHandlerQueries(unittest.TestCase):
|
|||
|
||||
def test_blob_unavailable_when_blob_cannot_be_opened(self):
|
||||
blob = mock.Mock()
|
||||
blob.is_validated.return_value = True
|
||||
blob.get_is_verified.return_value = True
|
||||
blob.open_for_reading.return_value = None
|
||||
self.blob_manager.get_blob.return_value = defer.succeed(blob)
|
||||
query = {
|
||||
|
@ -84,7 +84,7 @@ class TestBlobRequestHandlerQueries(unittest.TestCase):
|
|||
|
||||
def test_blob_details_are_set_when_all_conditions_are_met(self):
|
||||
blob = mock.Mock()
|
||||
blob.is_validated.return_value = True
|
||||
blob.get_is_verified.return_value = True
|
||||
blob.open_for_reading.return_value = True
|
||||
blob.blob_hash = 'DEADBEEF'
|
||||
blob.length = 42
|
||||
|
|
Loading…
Add table
Reference in a new issue