mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
wallet.py: small optimisation for get_wallet_delta
This commit is contained in:
parent
5284aef820
commit
0be73ed546
1 changed files with 7 additions and 8 deletions
|
@ -541,20 +541,19 @@ class Abstract_Wallet(PrintError):
|
||||||
|
|
||||||
def get_wallet_delta(self, tx):
|
def get_wallet_delta(self, tx):
|
||||||
""" effect of tx on wallet """
|
""" effect of tx on wallet """
|
||||||
addresses = self.get_addresses()
|
is_relevant = False # "related to wallet?"
|
||||||
is_relevant = False
|
|
||||||
is_mine = False
|
is_mine = False
|
||||||
is_pruned = False
|
is_pruned = False
|
||||||
is_partial = False
|
is_partial = False
|
||||||
v_in = v_out = v_out_mine = 0
|
v_in = v_out = v_out_mine = 0
|
||||||
for item in tx.inputs():
|
for txin in tx.inputs():
|
||||||
addr = item.get('address')
|
addr = txin.get('address')
|
||||||
if addr in addresses:
|
if self.is_mine(addr):
|
||||||
is_mine = True
|
is_mine = True
|
||||||
is_relevant = True
|
is_relevant = True
|
||||||
d = self.txo.get(item['prevout_hash'], {}).get(addr, [])
|
d = self.txo.get(txin['prevout_hash'], {}).get(addr, [])
|
||||||
for n, v, cb in d:
|
for n, v, cb in d:
|
||||||
if n == item['prevout_n']:
|
if n == txin['prevout_n']:
|
||||||
value = v
|
value = v
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -569,7 +568,7 @@ class Abstract_Wallet(PrintError):
|
||||||
is_partial = False
|
is_partial = False
|
||||||
for addr, value in tx.get_outputs():
|
for addr, value in tx.get_outputs():
|
||||||
v_out += value
|
v_out += value
|
||||||
if addr in addresses:
|
if self.is_mine(addr):
|
||||||
v_out_mine += value
|
v_out_mine += value
|
||||||
is_relevant = True
|
is_relevant = True
|
||||||
if is_pruned:
|
if is_pruned:
|
||||||
|
|
Loading…
Add table
Reference in a new issue