From 382cc387f088a4bc46125f1190f97bc093fa08a6 Mon Sep 17 00:00:00 2001 From: Marcelo Salhab Brogliato Date: Thu, 9 Nov 2023 09:55:44 -0600 Subject: [PATCH] feat(sync-v2): Stop streaming of transactions if an unexpected vertex is received --- hathor/p2p/sync_v2/transaction_streaming_client.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hathor/p2p/sync_v2/transaction_streaming_client.py b/hathor/p2p/sync_v2/transaction_streaming_client.py index 7a3837405..e41560e12 100644 --- a/hathor/p2p/sync_v2/transaction_streaming_client.py +++ b/hathor/p2p/sync_v2/transaction_streaming_client.py @@ -17,7 +17,12 @@ from structlog import get_logger from twisted.internet.defer import Deferred -from hathor.p2p.sync_v2.exception import InvalidVertexError, StreamingError, TooManyVerticesReceivedError +from hathor.p2p.sync_v2.exception import ( + InvalidVertexError, + StreamingError, + TooManyVerticesReceivedError, + UnexpectedVertex, +) from hathor.p2p.sync_v2.streamers import StreamEnd from hathor.transaction import BaseTransaction from hathor.transaction.exceptions import HathorError, TxValidationError @@ -105,9 +110,8 @@ def handle_transaction(self, tx: BaseTransaction) -> None: # This case might happen during a resume, so we just log and keep syncing. self.log.debug('duplicated vertex received', tx_id=tx.hash.hex()) else: - # TODO Uncomment the following code to fail on receiving unexpected vertices. - # self.fails(UnexpectedVertex(tx.hash.hex())) self.log.info('unexpected vertex received', tx_id=tx.hash.hex()) + self.fails(UnexpectedVertex(tx.hash.hex())) return self._waiting_for.remove(tx.hash)