From cb9b320ed777414929cce730accd4a9c8729338c Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Thu, 12 Jul 2018 14:23:25 -0400 Subject: [PATCH] dropped make_claim in favor of wallet.claim_name --- lbrynet/daemon/Daemon.py | 6 ++---- lbrynet/daemon/Publisher.py | 26 +++++++++++--------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 778e942df..d3c5e639d 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -371,11 +371,9 @@ class Daemon(AuthJSONRPCServer): if not file_path: stream_hash = yield self.storage.get_stream_hash_for_sd_hash( claim_dict['stream']['source']['source']) - tx = yield publisher.publish_stream(name, bid, claim_dict, stream_hash, claim_address, - change_address) + tx = yield publisher.publish_stream(name, bid, claim_dict, stream_hash, claim_address) else: - tx = yield publisher.create_and_publish_stream(name, bid, claim_dict, file_path, - claim_address, change_address) + tx = yield publisher.create_and_publish_stream(name, bid, claim_dict, file_path, claim_address) if conf.settings['reflect_uploads']: d = reupload.reflect_file(publisher.lbry_file) d.addCallbacks(lambda _: log.info("Reflected new publication to lbry://%s", name), diff --git a/lbrynet/daemon/Publisher.py b/lbrynet/daemon/Publisher.py index 34a5402ea..a21ccede7 100644 --- a/lbrynet/daemon/Publisher.py +++ b/lbrynet/daemon/Publisher.py @@ -22,8 +22,7 @@ class Publisher(object): self.lbry_file = None @defer.inlineCallbacks - def create_and_publish_stream(self, name, bid, claim_dict, file_path, claim_address=None, - change_address=None): + 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): @@ -44,7 +43,9 @@ class Publisher(object): 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 = yield self.make_claim(name, bid, claim_dict, claim_address, change_address) + tx = yield self.wallet.claim_name( + 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 = yield self.storage.get_old_stream_hashes_for_claim_id( @@ -57,27 +58,22 @@ class Publisher(object): log.info("Removed old stream for claim update: %s", lbry_file.stream_hash) yield self.storage.save_content_claim( - self.lbry_file.stream_hash, get_certificate_lookup(tx, 0) + self.lbry_file.stream_hash, get_certificate_lookup(tx, 0).decode() ) defer.returnValue(tx) @defer.inlineCallbacks - def publish_stream(self, name, bid, claim_dict, stream_hash, claim_address=None, change_address=None): + def publish_stream(self, name, bid, claim_dict, stream_hash, holding_address=None): """Make a claim without creating a lbry file""" - claim_out = yield self.make_claim(name, bid, claim_dict, claim_address, change_address) + tx = yield self.wallet.claim_name( + name, bid, claim_dict, self.certificate, holding_address + ) if stream_hash: # the stream_hash returned from the db will be None if this isn't a stream we have yield self.storage.save_content_claim( - stream_hash, "%s:%i" % (claim_out['txid'], claim_out['nout']) + stream_hash, get_certificate_lookup(tx, 0).decode() ) self.lbry_file = [f for f in self.lbry_file_manager.lbry_files if f.stream_hash == stream_hash][0] - defer.returnValue(claim_out) - - @defer.inlineCallbacks - def make_claim(self, name, bid, claim_dict, claim_address=None, change_address=None): - claim_out = yield self.wallet.claim_name( - name, bid, claim_dict, certificate=self.certificate, claim_address=claim_address - ) - defer.returnValue(claim_out) + defer.returnValue(tx) def get_content_type(filename):