Browse Source

Merge #795: gettransaction called once per txid in monitor

4c44932 gettransaction called once per txid in monitor (Adam Gibson)
master
Adam Gibson 5 years ago
parent
commit
67ebdb2c62
No known key found for this signature in database
GPG Key ID: 141001A1AF77F20B
  1. 14
      jmclient/jmclient/wallet_service.py

14
jmclient/jmclient/wallet_service.py

@ -309,11 +309,19 @@ class WalletService(Service):
if x['txid'] in self.active_txids or x['txid'] not in self.old_txs:
new_txs.append(x)
# reset for next polling event:
self.old_txs = [x['txid'] for x in txlist if "txid" in x]
self.old_txs = set(x['txid'] for x in txlist if "txid" in x)
# for this invocation of transaction_monitor, we *don't* want
# to call `gettransaction` more than once per txid, even if the
# `listtransactions` result has multiple instances for different
# wallet labels; so we use a temporary variable to cache.
gettx_results = {}
for tx in new_txs:
txid = tx["txid"]
res = self.bci.get_transaction(hextobin(txid))
if txid not in gettx_results:
res = self.bci.get_transaction(hextobin(txid))
gettx_results[txid] = res
else:
res = gettx_results[txid]
if not res:
continue
confs = res["confirmations"]

Loading…
Cancel
Save