diff --git a/lbrynet/core/LBRYcrdWallet.py b/lbrynet/core/LBRYcrdWallet.py index 0d1d2dc65..970072f77 100644 --- a/lbrynet/core/LBRYcrdWallet.py +++ b/lbrynet/core/LBRYcrdWallet.py @@ -410,7 +410,8 @@ class LBRYWallet(object): def update_name(self, name, value, amount): d = self._get_value_for_name(name) - d.addCallback(lambda r: self._update_name(r['txid'], json.dumps(value), amount)) + d.addCallback(lambda r: (self._update_name(json.loads(r)['txid'], json.dumps(value), amount), json.loads(r)['txid'])) + d.addCallback(lambda new_txid, old_txid: self._update_name_metadata(name, value['sources']['lbry_sd_hash'], old_txid, new_txid)) return d def get_name_and_validity_for_sd_hash(self, sd_hash): @@ -527,6 +528,12 @@ class LBRYWallet(object): return d + def _update_name_metadata(self, name, sd_hash, old_txid, new_txid): + d = self.db.runQuery("delete from name_metadata where txid=? and sd_hash=?", (old_txid, sd_hash)) + d.addCallback(lambda _: self.db.runQuery("insert into name_metadata values (?, ?, ?)", (name, new_txid, sd_hash))) + d.addCallback(lambda _: new_txid) + return d + def _get_claim_metadata_for_sd_hash(self, sd_hash): d = self.db.runQuery("select name, txid from name_metadata where sd_hash=?", (sd_hash,)) d.addCallback(lambda r: r[0] if len(r) else None) diff --git a/lbrynet/lbrynet_daemon/LBRYDaemon.py b/lbrynet/lbrynet_daemon/LBRYDaemon.py index 89e650eb0..acd13939f 100644 --- a/lbrynet/lbrynet_daemon/LBRYDaemon.py +++ b/lbrynet/lbrynet_daemon/LBRYDaemon.py @@ -399,11 +399,8 @@ class LBRYDaemon(jsonrpc.JSONRPC): def setup(self, branch=DEFAULT_UI_BRANCH, user_specified=False, branch_specified=False): def _log_starting_vals(): - d = self._get_lbry_files() - d.addCallback(lambda r: json.dumps([d[1] if not isinstance(d[1], UnknownNameError) else {'error': 'Pending claim'} for d in r])) - d.addCallback(lambda r: log.info("LBRY Files: " + r)) - d.addCallback(lambda _: log.info("Starting balance: " + str(self.session.wallet.wallet_balance))) - return d + log.info("Starting balance: " + str(self.session.wallet.wallet_balance)) + return defer.succeed(None) def _announce_startup(): def _wait_for_credits(): @@ -2138,17 +2135,17 @@ class LBRYDaemon(jsonrpc.JSONRPC): Args: 'name': the uri of the claim to be updated - 'value': new metadata dict + 'metadata': new metadata dict 'amount': bid amount of updated claim Returns: txid """ - + name = p['name'] - value = p['value'] if isinstance(p['value'], dict) else json.loads(p['value']) + metadata = p['metadata'] if isinstance(p['metadata'], dict) else json.loads(p['metadata']) amount = p['amount'] - d = self.session.wallet.update_name(name, value, amount) + d = self.session.wallet.update_name(name, metadata, amount) d.addCallback(lambda r: self._render_response(r, OK_CODE)) return d