Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sync-v2): Stop streaming of transactions if an unexpected vertex is received #856

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading