add claim txid and uri to lbry_file

This commit is contained in:
Jack 2016-05-10 19:03:14 -04:00
parent 74250982d1
commit 42a3006f6e
3 changed files with 19 additions and 4 deletions

View file

@ -530,8 +530,10 @@ class LBRYWallet(object):
" sd_hash text)") " sd_hash text)")
def _save_name_metadata(self, name, sd_hash, txid): def _save_name_metadata(self, name, sd_hash, txid):
d = self.db.runQuery("insert into name_metadata values (?, ?, ?)", d = self.db.runQuery("select * from name_metadata where txid=?", (txid,))
(name, txid, sd_hash)) d.addCallback(lambda r: self.db.runQuery("insert into name_metadata values (?, ?, ?)", (name, txid, sd_hash))
if not len(r) else None)
return d return d
def _get_claim_metadata_for_sd_hash(self, sd_hash): def _get_claim_metadata_for_sd_hash(self, sd_hash):

View file

@ -25,6 +25,8 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
stream_info_manager, payment_rate_manager, wallet, download_directory, stream_info_manager, payment_rate_manager, wallet, download_directory,
upload_allowed, file_name) upload_allowed, file_name)
self.sd_hash = None self.sd_hash = None
self.txid = None
self.uri = None
self.rowid = rowid self.rowid = rowid
self.lbry_file_manager = lbry_file_manager self.lbry_file_manager = lbry_file_manager
self.saving_status = False self.saving_status = False
@ -35,10 +37,19 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
def _save_sd_hash(sd_hash): def _save_sd_hash(sd_hash):
if len(sd_hash): if len(sd_hash):
self.sd_hash = sd_hash[0] self.sd_hash = sd_hash[0]
d = self.wallet._get_claim_metadata_for_sd_hash(self.sd_hash)
else:
d = defer.succeed(None)
return d
def _save_claim(name, txid):
self.uri = name
self.txid = txid
return defer.succeed(None) return defer.succeed(None)
d.addCallback(_save_sd_hash) d.addCallback(_save_sd_hash)
d.addCallback(lambda r: _save_claim(r[0], r[1]) if r else None)
d.addCallback(lambda _: self.lbry_file_manager.get_lbry_file_status(self)) d.addCallback(lambda _: self.lbry_file_manager.get_lbry_file_status(self))
def restore_status(status): def restore_status(status):

View file

@ -1101,6 +1101,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
'stream_name': f.stream_name, 'stream_name': f.stream_name,
'suggested_file_name': f.suggested_file_name, 'suggested_file_name': f.suggested_file_name,
'upload_allowed': f.upload_allowed, 'sd_hash': f.sd_hash, 'upload_allowed': f.upload_allowed, 'sd_hash': f.sd_hash,
'lbry_uri': f.uri, 'txid': f.txid,
'total_bytes': size, 'total_bytes': size,
'written_bytes': written_bytes, 'code': status[0], 'written_bytes': written_bytes, 'code': status[0],
'message': message}) 'message': message})
@ -1109,7 +1110,8 @@ class LBRYDaemon(jsonrpc.JSONRPC):
'points_paid': f.points_paid, 'stopped': f.stopped, 'stream_hash': f.stream_hash, 'points_paid': f.points_paid, 'stopped': f.stopped, 'stream_hash': f.stream_hash,
'stream_name': f.stream_name, 'suggested_file_name': f.suggested_file_name, 'stream_name': f.stream_name, 'suggested_file_name': f.suggested_file_name,
'upload_allowed': f.upload_allowed, 'sd_hash': f.sd_hash, 'total_bytes': size, 'upload_allowed': f.upload_allowed, 'sd_hash': f.sd_hash, 'total_bytes': size,
'written_bytes': written_bytes, 'code': status[0], 'message': status[1]}) 'written_bytes': written_bytes, 'lbry_uri': f.uri, 'txid': f.txid,
'code': status[0], 'message': status[1]})
return d return d