Skip to content

Commit

Permalink
feat(sync-v2): Stop streaming of transactions if an unexpected vertex…
Browse files Browse the repository at this point in the history
… is received
  • Loading branch information
msbrogli committed Nov 9, 2023
1 parent bce9f71 commit 382cc38
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hathor/p2p/sync_v2/transaction_streaming_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 382cc38

Please sign in to comment.