Merge pull request #387 from lbryio/wallet-whitespace
cleanup whitespace for increased readability
This commit is contained in:
commit
69c0da695b
1 changed files with 31 additions and 13 deletions
|
@ -502,7 +502,9 @@ class Wallet(object):
|
||||||
|
|
||||||
def get_claim(self, name, claim_id):
|
def get_claim(self, name, claim_id):
|
||||||
d = self.get_claims_for_name(name)
|
d = self.get_claims_for_name(name)
|
||||||
d.addCallback(lambda claims: next(claim for claim in claims['claims'] if claim['claimId'] == claim_id))
|
d.addCallback(
|
||||||
|
lambda claims: next(
|
||||||
|
claim for claim in claims['claims'] if claim['claimId'] == claim_id))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def get_claimid(self, name, txid, nout):
|
def get_claimid(self, name, txid, nout):
|
||||||
|
@ -511,8 +513,13 @@ class Wallet(object):
|
||||||
return defer.succeed(claim_id)
|
return defer.succeed(claim_id)
|
||||||
else:
|
else:
|
||||||
d = self.get_claims_from_tx(txid)
|
d = self.get_claims_from_tx(txid)
|
||||||
d.addCallback(lambda claims: next(c for c in claims if c['name'] == name and c['nOut'] == claim_outpoint['nout']))
|
d.addCallback(
|
||||||
d.addCallback(lambda claim: self._update_claimid(claim['claimId'], name, ClaimOutpoint(txid, claim['nOut'])))
|
lambda claims: next(
|
||||||
|
c for c in claims if c['name'] == name and
|
||||||
|
c['nOut'] == claim_outpoint['nout']))
|
||||||
|
d.addCallback(
|
||||||
|
lambda claim: self._update_claimid(
|
||||||
|
claim['claimId'], name, ClaimOutpoint(txid, claim['nOut'])))
|
||||||
return d
|
return d
|
||||||
claim_outpoint = ClaimOutpoint(txid, nout)
|
claim_outpoint = ClaimOutpoint(txid, nout)
|
||||||
d = self._get_claimid_for_tx(name, claim_outpoint)
|
d = self._get_claimid_for_tx(name, claim_outpoint)
|
||||||
|
@ -526,10 +533,14 @@ class Wallet(object):
|
||||||
claim['value'] = json.loads(claim['value'])
|
claim['value'] = json.loads(claim['value'])
|
||||||
return claim
|
return claim
|
||||||
|
|
||||||
|
|
||||||
def _get_my_unspent_claim(claims):
|
def _get_my_unspent_claim(claims):
|
||||||
for claim in claims:
|
for claim in claims:
|
||||||
if claim['name'] == name and not claim['is spent'] and claim['category'] != 'support':
|
is_unspent = (
|
||||||
|
claim['name'] == name and
|
||||||
|
not claim['is spent'] and
|
||||||
|
not claim.get('supported_claimid', False)
|
||||||
|
)
|
||||||
|
if is_unspent:
|
||||||
return claim
|
return claim
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -556,8 +567,10 @@ class Wallet(object):
|
||||||
result['txid'] = claim['txid']
|
result['txid'] = claim['txid']
|
||||||
result['nout'] = claim['n']
|
result['nout'] = claim['n']
|
||||||
result['value'] = metadata if metadata else json.loads(claim['value'])
|
result['value'] = metadata if metadata else json.loads(claim['value'])
|
||||||
result['supports'] = [{'txid': support['txid'], 'n': support['n']} for support in claim['supports']]
|
result['supports'] = [
|
||||||
result['meta_version'] = meta_version if meta_version else result['value'].get('ver', '0.0.1')
|
{'txid': support['txid'], 'n': support['n']} for support in claim['supports']]
|
||||||
|
result['meta_version'] = (
|
||||||
|
meta_version if meta_version else result['value'].get('ver', '0.0.1'))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _get_claim_info(self, name, claim_outpoint):
|
def _get_claim_info(self, name, claim_outpoint):
|
||||||
|
@ -576,8 +589,9 @@ class Wallet(object):
|
||||||
claim,
|
claim,
|
||||||
metadata=metadata,
|
metadata=metadata,
|
||||||
meta_version=meta_ver))
|
meta_version=meta_ver))
|
||||||
log.debug("get claim info lbry://%s metadata: %s, claimid: %s", name, meta_ver, claim['claimId'])
|
log.info(
|
||||||
|
"get claim info lbry://%s metadata: %s, claimid: %s",
|
||||||
|
name, meta_ver, claim['claimId'])
|
||||||
return d
|
return d
|
||||||
|
|
||||||
d = self.get_claimid(name, claim_outpoint['txid'], claim_outpoint['nout'])
|
d = self.get_claimid(name, claim_outpoint['txid'], claim_outpoint['nout'])
|
||||||
|
@ -603,7 +617,8 @@ class Wallet(object):
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
claim_out.pop('success')
|
claim_out.pop('success')
|
||||||
claim_outpoint = ClaimOutpoint(claim_out['txid'], claim_out['nout'])
|
claim_outpoint = ClaimOutpoint(claim_out['txid'], claim_out['nout'])
|
||||||
log.debug("Saving metadata for claim %s %d" % (claim_outpoint['txid'], claim_outpoint['nout']))
|
log.info("Saving metadata for claim %s %d",
|
||||||
|
claim_outpoint['txid'], claim_outpoint['nout'])
|
||||||
d = self._save_name_metadata(name, claim_outpoint, metadata['sources']['lbry_sd_hash'])
|
d = self._save_name_metadata(name, claim_outpoint, metadata['sources']['lbry_sd_hash'])
|
||||||
d.addCallback(lambda _: claim_out)
|
d.addCallback(lambda _: claim_out)
|
||||||
return d
|
return d
|
||||||
|
@ -616,9 +631,10 @@ class Wallet(object):
|
||||||
log.debug("Updating over own claim")
|
log.debug("Updating over own claim")
|
||||||
d = self.update_metadata(metadata, claim['value'])
|
d = self.update_metadata(metadata, claim['value'])
|
||||||
claim_outpoint = ClaimOutpoint(claim['txid'], claim['nOut'])
|
claim_outpoint = ClaimOutpoint(claim['txid'], claim['nOut'])
|
||||||
d.addCallback(lambda new_metadata: self._send_name_claim_update(name, claim['claim_id'],
|
d.addCallback(
|
||||||
claim_outpoint,
|
lambda new_metadata: self._send_name_claim_update(name, claim['claim_id'],
|
||||||
new_metadata, _bid))
|
claim_outpoint,
|
||||||
|
new_metadata, _bid))
|
||||||
return d
|
return d
|
||||||
|
|
||||||
meta = Metadata(m)
|
meta = Metadata(m)
|
||||||
|
@ -997,6 +1013,8 @@ class LBRYumWallet(Wallet):
|
||||||
|
|
||||||
# run commands as a deferToThread, lbryum commands that only make
|
# run commands as a deferToThread, lbryum commands that only make
|
||||||
# queries to lbryum server should be run this way
|
# queries to lbryum server should be run this way
|
||||||
|
# TODO: keep track of running threads and cancel them on `stop`
|
||||||
|
# otherwise the application will hang, waiting for threads to complete
|
||||||
def _run_cmd_as_defer_to_thread(self, command_name, *args):
|
def _run_cmd_as_defer_to_thread(self, command_name, *args):
|
||||||
cmd_runner = self._get_cmd_runner()
|
cmd_runner = self._get_cmd_runner()
|
||||||
cmd = known_commands[command_name]
|
cmd = known_commands[command_name]
|
||||||
|
|
Loading…
Reference in a new issue