transaction lock

This commit is contained in:
ecdsa 2013-03-24 07:34:28 +01:00
parent 3dc9677822
commit 29b9ffac4a
1 changed files with 25 additions and 27 deletions

View File

@ -113,6 +113,7 @@ class Wallet:
self.up_to_date = False
self.lock = threading.Lock()
self.transaction_lock = threading.Lock()
self.tx_event = threading.Event()
if self.seed_version != SEED_VERSION:
@ -432,7 +433,6 @@ class Wallet:
for item in tx.outputs:
addr, value = item
key = tx_hash+ ':%d'%i
with self.lock:
self.prevout_values[key] = value
i += 1
@ -607,18 +607,16 @@ class Wallet:
def receive_tx_callback(self, tx_hash, tx, tx_height):
if not self.check_new_tx(tx_hash, tx):
# may happen due to pruning
print_error("received transaction that is no longer referenced in history", tx_hash)
return
with self.lock:
with self.transaction_lock:
self.transactions[tx_hash] = tx
#tx_height = tx.get('height')
if self.verifier and tx_height>0:
self.verifier.add(tx_hash, tx_height)
self.update_tx_outputs(tx_hash)
self.save()
@ -641,7 +639,7 @@ class Wallet:
def get_tx_history(self):
with self.lock:
with self.transaction_lock:
history = self.transactions.items()
history.sort(key = lambda x: self.verifier.verified_tx.get(x[0]) if self.verifier.verified_tx.get(x[0]) else (1e12,0,0))
result = []