mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Refactors Responder and BlockProcessor
Brings check_confirmations back to the Responder
This commit is contained in:
@@ -153,9 +153,7 @@ class Responder:
|
||||
|
||||
# ToDo: #9-add-data-persistence
|
||||
if prev_block_hash == block.get("previousblockhash"):
|
||||
self.unconfirmed_txs, self.missed_confirmations = BlockProcessor.check_confirmations(
|
||||
txs, self.unconfirmed_txs, self.tx_job_map, self.missed_confirmations
|
||||
)
|
||||
self.check_confirmations(txs)
|
||||
|
||||
txs_to_rebroadcast = self.get_txs_to_rebroadcast(txs)
|
||||
completed_jobs = self.get_completed_jobs(height)
|
||||
@@ -186,6 +184,26 @@ class Responder:
|
||||
|
||||
logger.info("No more pending jobs, going back to sleep")
|
||||
|
||||
# NOTCOVERED
|
||||
def check_confirmations(self, txs):
|
||||
|
||||
for tx in txs:
|
||||
if tx in self.tx_job_map and tx in self.unconfirmed_txs:
|
||||
self.unconfirmed_txs.remove(tx)
|
||||
|
||||
logger.info("Confirmation received for transaction", tx=tx)
|
||||
|
||||
elif tx in self.unconfirmed_txs:
|
||||
if tx in self.missed_confirmations:
|
||||
self.missed_confirmations[tx] += 1
|
||||
|
||||
else:
|
||||
self.missed_confirmations[tx] = 1
|
||||
|
||||
logger.info(
|
||||
"Transaction missed a confirmation", tx=tx, missed_confirmations=self.missed_confirmations[tx]
|
||||
)
|
||||
|
||||
def get_txs_to_rebroadcast(self, txs):
|
||||
txs_to_rebroadcast = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user