From 5abeceac1fd39e147caa0955173ed58bc58e1c6c Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 27 Jul 2016 01:13:41 -0400 Subject: [PATCH] abandon previous claim in update --- lbrynet/lbrynet_daemon/LBRYDaemon.py | 11 +++++++++-- lbrynet/lbrynet_daemon/LBRYPublisher.py | 12 +++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 8c04cf345..6ecafb741 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -1911,7 +1911,13 @@ class LBRYDaemon(jsonrpc.JSONRPC): metadata['fee'][currency]['address'] = address return defer.succeed(None) - d = defer.succeed(None) + def _delete_data(lbry_file): + txid = lbry_file.txid + d = self._delete_lbry_file(lbry_file, delete_file=False) + d.addCallback(lambda _: txid) + return d + + d = self._resolve_name(name, force_refresh=True) if 'fee' in p: metadata['fee'] = p['fee'] @@ -1923,7 +1929,8 @@ class LBRYDaemon(jsonrpc.JSONRPC): pub = Publisher(self.session, self.lbry_file_manager, self.session.wallet) d.addCallback(lambda _: self._get_lbry_file_by_uri(name)) - d.addCallback(lambda r: pub.start(name, file_path, bid, metadata, None if r is None else r.txid)) + d.addCallback(lambda l: None if not l else _delete_data(l)) + d.addCallback(lambda r: pub.start(name, file_path, bid, metadata, r)) d.addCallbacks(lambda msg: self._render_response(msg, OK_CODE), lambda err: self._render_response(err.getTraceback(), BAD_REQUEST)) diff --git a/lbrynet/lbrynet_daemon/LBRYPublisher.py b/lbrynet/lbrynet_daemon/LBRYPublisher.py index 4d27a6973..f27e6e48b 100644 --- a/lbrynet/lbrynet_daemon/LBRYPublisher.py +++ b/lbrynet/lbrynet_daemon/LBRYPublisher.py @@ -46,7 +46,7 @@ class Publisher(object): self.stream_hash = None self.metadata = {} - def start(self, name, file_path, bid, metadata, old_txid=None): + def start(self, name, file_path, bid, metadata, old_txid): def _show_result(): log.info("Published %s --> lbry://%s txid: %s", self.file_name, self.publish_name, self.txid) @@ -111,10 +111,12 @@ class Publisher(object): self.metadata['ver'] = CURRENT_METADATA_VERSION if self.old_txid: - d = self.wallet.update_name(self.publish_name, - self.bid_amount, - Metadata(self.metadata), - self.old_txid) + + d = self.wallet.abandon_name(self.old_txid) + d.addCallback(lambda tx: log.info("Abandoned tx %s" % str(tx))) + d.addCallback(lambda _: self.wallet.claim_name(self.publish_name, + self.bid_amount, + Metadata(self.metadata))) else: d = self.wallet.claim_name(self.publish_name, self.bid_amount,