mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Fixes potential runtime errors for dictionaries changing size
This commit is contained in:
@@ -190,8 +190,9 @@ class Gatekeeper:
|
|||||||
:obj:`list`: a list of appointment uuids that will expire at ``block_height``.
|
:obj:`list`: a list of appointment uuids that will expire at ``block_height``.
|
||||||
"""
|
"""
|
||||||
expired_appointments = []
|
expired_appointments = []
|
||||||
for user_id, user_info in self.registered_users.items():
|
# Avoiding dictionary changed size during iteration
|
||||||
if block_height == user_info.subscription_expiry + self.expiry_delta:
|
for user_id in list(self.registered_users.keys()):
|
||||||
expired_appointments.extend(user_info.appointments)
|
if block_height == self.registered_users[user_id].subscription_expiry + self.expiry_delta:
|
||||||
|
expired_appointments.extend(self.registered_users[user_id].appointments)
|
||||||
|
|
||||||
return expired_appointments
|
return expired_appointments
|
||||||
|
|||||||
@@ -337,7 +337,6 @@ class Responder:
|
|||||||
for tx in self.unconfirmed_txs:
|
for tx in self.unconfirmed_txs:
|
||||||
if tx in self.missed_confirmations:
|
if tx in self.missed_confirmations:
|
||||||
self.missed_confirmations[tx] += 1
|
self.missed_confirmations[tx] += 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.missed_confirmations[tx] = 1
|
self.missed_confirmations[tx] = 1
|
||||||
|
|
||||||
@@ -374,16 +373,18 @@ class Responder:
|
|||||||
# the responder.
|
# the responder.
|
||||||
checked_txs = {}
|
checked_txs = {}
|
||||||
|
|
||||||
for uuid, tracker_data in self.trackers.items():
|
# Avoiding dictionary changed size during iteration
|
||||||
if tracker_data.get("penalty_txid") not in self.unconfirmed_txs:
|
for uuid in list(self.trackers.keys()):
|
||||||
if tracker_data.get("penalty_txid") not in checked_txs:
|
penalty_txid = self.trackers[uuid].get("penalty_txid")
|
||||||
tx = self.carrier.get_transaction(tracker_data.get("penalty_txid"))
|
if penalty_txid not in self.unconfirmed_txs:
|
||||||
|
if penalty_txid not in checked_txs:
|
||||||
|
tx = self.carrier.get_transaction(penalty_txid)
|
||||||
else:
|
else:
|
||||||
tx = checked_txs.get(tracker_data.get("penalty_txid"))
|
tx = checked_txs.get(penalty_txid)
|
||||||
|
|
||||||
if tx is not None:
|
if tx is not None:
|
||||||
confirmations = tx.get("confirmations")
|
confirmations = tx.get("confirmations")
|
||||||
checked_txs[tracker_data.get("penalty_txid")] = tx
|
checked_txs[penalty_txid] = tx
|
||||||
|
|
||||||
if confirmations is not None and confirmations >= IRREVOCABLY_RESOLVED:
|
if confirmations is not None and confirmations >= IRREVOCABLY_RESOLVED:
|
||||||
completed_trackers.append(uuid)
|
completed_trackers.append(uuid)
|
||||||
@@ -464,7 +465,8 @@ class Responder:
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for uuid in self.trackers.keys():
|
# Avoiding dictionary changed size during iteration
|
||||||
|
for uuid in list(self.trackers.keys()):
|
||||||
tracker = TransactionTracker.from_dict(self.db_manager.load_responder_tracker(uuid))
|
tracker = TransactionTracker.from_dict(self.db_manager.load_responder_tracker(uuid))
|
||||||
|
|
||||||
# First we check if the dispute transaction is known (exists either in mempool or blockchain)
|
# First we check if the dispute transaction is known (exists either in mempool or blockchain)
|
||||||
|
|||||||
Reference in New Issue
Block a user