1
0

simplify add_transaction

This commit is contained in:
ThomasV
2019-11-23 12:46:43 +01:00
parent fc85dcead6
commit 06589df812
4 changed files with 13 additions and 13 deletions

View File

@@ -207,11 +207,11 @@ class AddressSynchronizer(Logger):
conflicting_txns -= {tx_hash}
return conflicting_txns
def add_transaction(self, tx_hash, tx: Transaction, allow_unrelated=False) -> bool:
def add_transaction(self, tx: Transaction, allow_unrelated=False) -> bool:
"""Returns whether the tx was successfully added to the wallet history."""
assert tx_hash, tx_hash
assert tx, tx
assert tx.is_complete()
tx_hash = tx.txid()
# assert tx_hash == tx.txid() # disabled as expensive; test done by Synchronizer.
# we need self.transaction_lock but get_tx_height will take self.lock
# so we need to take that too here, to enforce order of locks
@@ -339,7 +339,7 @@ class AddressSynchronizer(Logger):
def receive_tx_callback(self, tx_hash, tx, tx_height):
self.add_unverified_tx(tx_hash, tx_height)
self.add_transaction(tx_hash, tx, allow_unrelated=True)
self.add_transaction(tx, allow_unrelated=True)
def receive_history_callback(self, addr: str, hist, tx_fees: Dict[str, int]):
with self.lock:
@@ -360,7 +360,7 @@ class AddressSynchronizer(Logger):
tx = self.db.get_transaction(tx_hash)
if tx is None:
continue
self.add_transaction(tx_hash, tx, allow_unrelated=True)
self.add_transaction(tx, allow_unrelated=True)
# Store fees
for tx_hash, fee_sat in tx_fees.items():
@@ -386,7 +386,7 @@ class AddressSynchronizer(Logger):
continue
tx = self.db.get_transaction(tx_hash)
if tx is not None:
self.add_transaction(tx_hash, tx, allow_unrelated=True)
self.add_transaction(tx, allow_unrelated=True)
def remove_local_transactions_we_dont_have(self):
for txid in itertools.chain(self.db.list_txi(), self.db.list_txo()):
@@ -569,7 +569,7 @@ class AddressSynchronizer(Logger):
def add_future_tx(self, tx: Transaction, num_blocks: int) -> None:
assert num_blocks > 0, num_blocks
with self.lock:
self.add_transaction(tx.txid(), tx)
self.add_transaction(tx)
self.future_tx[tx.txid()] = num_blocks
def get_tx_height(self, tx_hash: str) -> TxMinedInfo: