blob_reflect fix

This commit is contained in:
Lex Berezhny 2019-01-10 18:40:20 -05:00
parent ebdb33bd11
commit b0deb63129
3 changed files with 7 additions and 11 deletions

View file

@ -3310,7 +3310,7 @@ class Daemon(metaclass=JSONRPCServerType):
return blob_hashes[start_index:stop_index]
@requires(BLOB_COMPONENT)
def jsonrpc_blob_reflect(self, blob_hashes, reflector_server=None):
async def jsonrpc_blob_reflect(self, blob_hashes, reflector_server=None):
"""
Reflects specified blobs
@ -3323,7 +3323,8 @@ class Daemon(metaclass=JSONRPCServerType):
Returns:
(list) reflected blob hashes
"""
return d2f(reupload.reflect_blob_hashes(blob_hashes, self.blob_manager, reflector_server))
result = await d2f(reupload.reflect_blob_hashes(blob_hashes, self.blob_manager, reflector_server))
return result
@requires(BLOB_COMPONENT)
async def jsonrpc_blob_reflect_all(self):

View file

@ -165,15 +165,10 @@ class BlobReflectorClient(Protocol):
blob_hash = self.blob_hashes_to_send[0]
log.debug('No current blob, sending the next one: %s', blob_hash)
self.blob_hashes_to_send = self.blob_hashes_to_send[1:]
d = self.blob_manager.get_blob(blob_hash)
d.addCallback(self.open_blob_for_reading)
blob = self.blob_manager.get_blob(blob_hash)
self.open_blob_for_reading(blob)
# send the server the next blob hash + length
d.addCallbacks(
lambda _: self.send_blob_info(),
errback=log.fail(self.disconnect),
errbackArgs=("Error reflecting blob %s", blob_hash)
)
return d
return self.send_blob_info()
else:
# close connection
log.debug('No more blob hashes, closing connection')

View file

@ -45,7 +45,7 @@ def _reflect_blobs(blob_manager, blob_hashes, reflector_server):
ip = yield resolve(reflector_address)
yield reactor.connectTCP(ip, reflector_port, factory)
result = yield factory.finished_deferred
defer.returnValue(result)
return result
def reflect_file(lbry_file, reflector_server=None):