Browse Source
wallet.py: small optimisation for get_wallet_delta
3.2.x
SomberNight
7 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
1 changed files with
7 additions and
8 deletions
-
lib/wallet.py
|
@ -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: |
|
|