def create_stream(): test_file = GenFile(53209343, b''.join([chr(i + 5) for i in xrange(0, 64, 6)])) stream_hash = yield create_lbry_file(self.session, self.lbry_file_manager, "test_file", test_file, suggested_file_name="test_file") sd_hash = yield publish_sd_blob(self.stream_info_manager, self.session.blob_manager, stream_hash) defer.returnValue((stream_hash, sd_hash))
def create_and_publish_stream(self, name, bid, claim_dict, file_path, claim_address=None, change_address=None): """Create lbry file and make claim""" log.info('Starting publish for %s', name) if not os.path.isfile(file_path): raise Exception("File {} not found".format(file_path)) if os.path.getsize(file_path) == 0: raise Exception("Cannot publish empty file {}".format(file_path)) file_name = os.path.basename(file_path) with file_utils.get_read_handle(file_path) as read_handle: self.lbry_file = yield create_lbry_file(self.session, self.lbry_file_manager, file_name, read_handle) if 'source' not in claim_dict['stream']: claim_dict['stream']['source'] = {} claim_dict['stream']['source']['source'] = self.lbry_file.sd_hash claim_dict['stream']['source']['sourceType'] = 'lbry_sd_hash' claim_dict['stream']['source']['contentType'] = get_content_type(file_path) claim_dict['stream']['source']['version'] = "_0_0_1" # need current version here claim_out = yield self.make_claim(name, bid, claim_dict, claim_address, change_address) # check if we have a file already for this claim (if this is a publish update with a new stream) old_stream_hashes = yield self.session.storage.get_old_stream_hashes_for_claim_id(claim_out['claim_id'], self.lbry_file.stream_hash) if old_stream_hashes: for lbry_file in filter(lambda l: l.stream_hash in old_stream_hashes, list(self.lbry_file_manager.lbry_files)): yield self.lbry_file_manager.delete_lbry_file(lbry_file, delete_file=False) log.info("Removed old stream for claim update: %s", lbry_file.stream_hash) yield self.session.storage.save_content_claim( self.lbry_file.stream_hash, "%s:%i" % (claim_out['txid'], claim_out['nout']) ) defer.returnValue(claim_out)
def create_and_publish_stream(self, name, bid, claim_dict, file_path, claim_address=None, change_address=None): """Create lbry file and make claim""" log.info('Starting publish for %s', name) if not os.path.isfile(file_path): raise Exception("File {} not found".format(file_path)) if os.path.getsize(file_path) == 0: raise Exception("Cannot publish empty file {}".format(file_path)) file_name = os.path.basename(file_path) with file_utils.get_read_handle(file_path) as read_handle: self.lbry_file = yield create_lbry_file(self.session, self.lbry_file_manager, file_name, read_handle) if 'source' not in claim_dict['stream']: claim_dict['stream']['source'] = {} claim_dict['stream']['source']['source'] = self.lbry_file.sd_hash claim_dict['stream']['source']['sourceType'] = 'lbry_sd_hash' claim_dict['stream']['source']['contentType'] = get_content_type( file_path) claim_dict['stream']['source'][ 'version'] = "_0_0_1" # need current version here claim_out = yield self.make_claim(name, bid, claim_dict, claim_address, change_address) yield self.session.storage.save_content_claim( self.lbry_file.stream_hash, "%s:%i" % (claim_out['txid'], claim_out['nout'])) yield self.lbry_file.get_claim_info() defer.returnValue(claim_out)
def create_stream(self): test_file = GenFile(self.file_size, b''.join([chr(i) for i in xrange(0, 64, 6)])) lbry_file = yield create_lbry_file(self.session, self.lbry_file_manager, "test_file", test_file) defer.returnValue(lbry_file.sd_hash)
def create_stream(): test_file = GenFile( 5209343, b''.join([chr(i + 3) for i in xrange(0, 64, 6)])) d = create_lbry_file(self.session, self.lbry_file_manager, "test_file", test_file, key="0123456701234567", iv_generator=iv_generator()) return d
def create_stream(): test_file = GenFile(53209343, b''.join([chr(i + 5) for i in xrange(0, 64, 6)])) lbry_file = yield create_lbry_file(self.session, self.lbry_file_manager, "test_file", test_file) sd_hash = yield self.session.storage.get_sd_blob_hash_for_stream(lbry_file.stream_hash) self.assertTrue(lbry_file.sd_hash, sd_hash) yield lbry_file.start() f = open('test_file') hashsum = MD5.new() hashsum.update(f.read()) self.assertEqual(hashsum.hexdigest(), "68959747edc73df45e45db6379dd7b3b")
def create_stream(): test_file = GenFile( 53209343, b''.join([chr(i + 5) for i in xrange(0, 64, 6)])) stream_hash = yield create_lbry_file( self.session, self.lbry_file_manager, "test_file", test_file, suggested_file_name="test_file") yield publish_sd_blob(self.stream_info_manager, self.session.blob_manager, stream_hash) defer.returnValue(stream_hash)
def create_stream(): test_file = GenFile(5209343, bytes( (i + 3) for i in range(0, 64, 6))) d = create_lbry_file(self.blob_manager, self.storage, self.prm, self.lbry_file_manager, "test_file", test_file, key=b'0123456701234567', iv_generator=iv_generator()) d.addCallback(lambda lbry_file: lbry_file.stream_hash) return d
async def create_and_publish_stream(self, name, bid, claim_dict, file_path, holding_address=None): """Create lbry file and make claim""" log.info('Starting publish for %s', name) if not os.path.isfile(file_path): raise Exception("File {} not found".format(file_path)) if os.path.getsize(file_path) == 0: raise Exception("Cannot publish empty file {}".format(file_path)) file_name = os.path.basename(file_path) with open(file_path, 'rb') as read_handle: self.lbry_file = await d2f( create_lbry_file(self.blob_manager, self.storage, self.payment_rate_manager, self.lbry_file_manager, file_name, read_handle)) if 'source' not in claim_dict['stream']: claim_dict['stream']['source'] = {} claim_dict['stream']['source']['source'] = self.lbry_file.sd_hash claim_dict['stream']['source']['sourceType'] = 'lbry_sd_hash' claim_dict['stream']['source']['contentType'] = get_content_type( file_path) claim_dict['stream']['source'][ 'version'] = "_0_0_1" # need current version here tx = await self.wallet.claim_name(self.account, name, bid, claim_dict, self.certificate, holding_address) # check if we have a file already for this claim (if this is a publish update with a new stream) old_stream_hashes = await d2f( self.storage.get_old_stream_hashes_for_claim_id( tx.outputs[0].claim_id, self.lbry_file.stream_hash)) if old_stream_hashes: for lbry_file in filter( lambda l: l.stream_hash in old_stream_hashes, list(self.lbry_file_manager.lbry_files)): await d2f( self.lbry_file_manager.delete_lbry_file(lbry_file, delete_file=False)) log.info("Removed old stream for claim update: %s", lbry_file.stream_hash) await d2f( self.storage.save_content_claim(self.lbry_file.stream_hash, tx.outputs[0].id)) return tx
def test_create_and_combine_stream(self): test_file = GenFile(53209343, bytes((i + 5) for i in range(0, 64, 6))) lbry_file = yield create_lbry_file(self.blob_manager, self.storage, self.prm, self.lbry_file_manager, "test_file", test_file) sd_hash = yield self.storage.get_sd_blob_hash_for_stream( lbry_file.stream_hash) self.assertTrue(lbry_file.sd_hash, sd_hash) yield lbry_file.start() f = open('test_file', 'rb') hashsum = md5() hashsum.update(f.read()) self.assertEqual(hashsum.hexdigest(), "68959747edc73df45e45db6379dd7b3b")
def setup(self): init_conf_windows() self.db_dir, self.blob_dir = mk_db_and_blob_dir() self.wallet = FakeWallet() self.peer_manager = PeerManager() self.rate_limiter = RateLimiter() if self.ul_rate_limit is not None: self.rate_limiter.set_ul_limit(self.ul_rate_limit) self.prm = OnlyFreePaymentsManager() self.storage = SQLiteStorage(self.db_dir) self.blob_manager = DiskBlobManager(self.blob_dir, self.storage) self.lbry_file_manager = EncryptedFileManager( FakePeerFinder(5553, self.peer_manager, 1), self.rate_limiter, self.blob_manager, self.wallet, self.prm, self.storage, StreamDescriptorIdentifier()) yield self.storage.setup() yield self.blob_manager.setup() yield self.lbry_file_manager.setup() query_handler_factories = { 1: BlobAvailabilityHandlerFactory(self.blob_manager), 2: BlobRequestHandlerFactory(self.blob_manager, self.wallet, self.prm, None), 3: self.wallet.get_wallet_info_query_handler_factory(), } server_factory = ServerProtocolFactory(self.rate_limiter, query_handler_factories, self.peer_manager) self.server_port = reactor.listenTCP(5553, server_factory, interface="localhost") test_file = GenFile(self.file_size, b''.join([chr(i) for i in xrange(0, 64, 6)])) lbry_file = yield create_lbry_file(self.blob_manager, self.storage, self.prm, self.lbry_file_manager, "test_file", test_file) defer.returnValue(lbry_file.sd_hash)
def create_and_publish_stream(self, name, bid, claim_dict, file_path, claim_address=None, change_address=None): """Create lbry file and make claim""" log.info('Starting publish for %s', name) if not os.path.isfile(file_path): raise Exception("File {} not found".format(file_path)) if os.path.getsize(file_path) == 0: raise Exception("Cannot publish empty file {}".format(file_path)) file_name = os.path.basename(file_path) with file_utils.get_read_handle(file_path) as read_handle: stream_hash = yield create_lbry_file(self.session, self.lbry_file_manager, file_name, read_handle) prm = self.session.payment_rate_manager self.lbry_file = yield self.lbry_file_manager.add_lbry_file( stream_hash, prm) sd_hash = yield publish_sd_blob( self.lbry_file_manager.stream_info_manager, self.session.blob_manager, self.lbry_file.stream_hash) if 'source' not in claim_dict['stream']: claim_dict['stream']['source'] = {} claim_dict['stream']['source']['source'] = sd_hash claim_dict['stream']['source']['sourceType'] = 'lbry_sd_hash' claim_dict['stream']['source']['contentType'] = get_content_type( file_path) claim_dict['stream']['source'][ 'version'] = "_0_0_1" # need current version here claim_out = yield self.make_claim(name, bid, claim_dict, claim_address, change_address) self.lbry_file.completed = True yield self.lbry_file.load_file_attributes(sd_hash) yield self.lbry_file.save_status() defer.returnValue(claim_out)
def create_stream(self): test_file = GenFile(self.file_size, b''.join([chr(i) for i in xrange(0, 64, 6)])) d = create_lbry_file(self.session, self.lbry_file_manager, "test_file", test_file) return d
def create_stream(): test_file = GenFile(5209343, b''.join([chr(i + 3) for i in xrange(0, 64, 6)])) d = create_lbry_file(self.session, self.lbry_file_manager, "test_file", test_file, key="0123456701234567", iv_generator=iv_generator()) return d
def create_stream(self): test_file = GenFile(self.file_size, b''.join([chr(i) for i in xrange(0, 64, 6)])) d = create_lbry_file(self.session, self.lbry_file_manager, "test_file", test_file) return d