mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 01:35:20 +00:00
wallet: lock in get_addr_io, get_tx_delta, get_tx_value
probably fixes #4716
This commit is contained in:
parent
1b95cced5d
commit
435efb47d0
1 changed files with 22 additions and 13 deletions
|
@ -80,6 +80,12 @@ class AddressSynchronizer(PrintError):
|
||||||
|
|
||||||
self.load_and_cleanup()
|
self.load_and_cleanup()
|
||||||
|
|
||||||
|
def with_transaction_lock(func):
|
||||||
|
def func_wrapper(self, *args, **kwargs):
|
||||||
|
with self.transaction_lock:
|
||||||
|
return func(self, *args, **kwargs)
|
||||||
|
return func_wrapper
|
||||||
|
|
||||||
def load_and_cleanup(self):
|
def load_and_cleanup(self):
|
||||||
self.load_transactions()
|
self.load_transactions()
|
||||||
self.load_local_history()
|
self.load_local_history()
|
||||||
|
@ -651,8 +657,9 @@ class AddressSynchronizer(PrintError):
|
||||||
def is_up_to_date(self):
|
def is_up_to_date(self):
|
||||||
with self.lock: return self.up_to_date
|
with self.lock: return self.up_to_date
|
||||||
|
|
||||||
|
@with_transaction_lock
|
||||||
def get_tx_delta(self, tx_hash, address):
|
def get_tx_delta(self, tx_hash, address):
|
||||||
"effect of tx on address"
|
"""effect of tx on address"""
|
||||||
delta = 0
|
delta = 0
|
||||||
# substract the value of coins sent from address
|
# substract the value of coins sent from address
|
||||||
d = self.txi.get(tx_hash, {}).get(address, [])
|
d = self.txi.get(tx_hash, {}).get(address, [])
|
||||||
|
@ -664,8 +671,9 @@ class AddressSynchronizer(PrintError):
|
||||||
delta += v
|
delta += v
|
||||||
return delta
|
return delta
|
||||||
|
|
||||||
|
@with_transaction_lock
|
||||||
def get_tx_value(self, txid):
|
def get_tx_value(self, txid):
|
||||||
" effect of tx on the entire domain"
|
"""effect of tx on the entire domain"""
|
||||||
delta = 0
|
delta = 0
|
||||||
for addr, d in self.txi.get(txid, {}).items():
|
for addr, d in self.txi.get(txid, {}).items():
|
||||||
for n, v in d:
|
for n, v in d:
|
||||||
|
@ -728,17 +736,18 @@ class AddressSynchronizer(PrintError):
|
||||||
return is_relevant, is_mine, v, fee
|
return is_relevant, is_mine, v, fee
|
||||||
|
|
||||||
def get_addr_io(self, address):
|
def get_addr_io(self, address):
|
||||||
h = self.get_address_history(address)
|
with self.lock, self.transaction_lock:
|
||||||
received = {}
|
h = self.get_address_history(address)
|
||||||
sent = {}
|
received = {}
|
||||||
for tx_hash, height in h:
|
sent = {}
|
||||||
l = self.txo.get(tx_hash, {}).get(address, [])
|
for tx_hash, height in h:
|
||||||
for n, v, is_cb in l:
|
l = self.txo.get(tx_hash, {}).get(address, [])
|
||||||
received[tx_hash + ':%d'%n] = (height, v, is_cb)
|
for n, v, is_cb in l:
|
||||||
for tx_hash, height in h:
|
received[tx_hash + ':%d'%n] = (height, v, is_cb)
|
||||||
l = self.txi.get(tx_hash, {}).get(address, [])
|
for tx_hash, height in h:
|
||||||
for txi, v in l:
|
l = self.txi.get(tx_hash, {}).get(address, [])
|
||||||
sent[txi] = height
|
for txi, v in l:
|
||||||
|
sent[txi] = height
|
||||||
return received, sent
|
return received, sent
|
||||||
|
|
||||||
def get_addr_utxo(self, address):
|
def get_addr_utxo(self, address):
|
||||||
|
|
Loading…
Add table
Reference in a new issue