dropped make_claim in favor of wallet.claim_name

This commit is contained in:
Lex Berezhny 2018-07-12 14:23:25 -04:00 committed by Jack Robison
parent 1d906fb0c7
commit cb9b320ed7
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 13 additions and 19 deletions

View file

@ -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),

View file

@ -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):