Skip to content

Commit 93c2fb9

Browse files
committed
review changes
1 parent ea98b54 commit 93c2fb9

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

hathor/p2p/sync_v2/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,7 @@ def handle_transaction(self, payload: str) -> None:
947947
self.log.warn('not a transaction', hash=tx.hash_hex)
948948
# Not a transaction. Punish peer?
949949
return
950+
tx.storage = self.tx_storage
950951

951952
assert self._tx_streaming_client is not None
952953
self._tx_streaming_client.handle_transaction(tx)

hathor/p2p/sync_v2/blockchain_streaming_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def handle_blocks(self, blk: Block) -> None:
9393
self.fails(TooManyVerticesReceivedError())
9494
return
9595

96-
# Run basic verification.
96+
# TODO Run basic verification. We will uncomment these lines after we finish
97+
# refactoring our verification services.
98+
#
9799
# if not blk.is_genesis:
98100
# try:
99101
# self.manager.verification_service.validate_basic(blk)

hathor/p2p/sync_v2/exception.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ class StreamingError(Exception):
1818

1919

2020
class TooManyVerticesReceivedError(StreamingError):
21-
"""Raised when the other peer sent too many vertices."""
21+
"""Raised when the other peer has sent too many vertices."""
2222
pass
2323

2424

2525
class TooManyRepeatedVerticesError(StreamingError):
26-
"""Raised when the other peer sent too many repeated vertices."""
26+
"""Raised when the other peer has sent too many repeated vertices."""
2727
pass
2828

2929

@@ -38,4 +38,5 @@ class InvalidVertexError(StreamingError):
3838

3939

4040
class UnexpectedVertex(StreamingError):
41+
"""Raised when we are not expecting the received vertex."""
4142
pass

hathor/p2p/sync_v2/streamers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ def __init__(self,
216216
assert isinstance(self.first_block, Block)
217217
assert isinstance(self.last_block, Block)
218218

219-
# TODO Validated start_from and use it when it's not empty.
219+
# Validate that all transactions in `start_from` are confirmed by the first block.
220+
for tx in start_from:
221+
assert tx.get_metadata().first_block == first_block_hash
220222

221223
self.current_block: Optional[Block] = self.first_block
222224
self.bfs = BFSOrderWalk(self.tx_storage, is_dag_verifications=True, is_dag_funds=True, is_left_to_right=False)

hathor/p2p/sync_v2/transaction_streaming_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
)
2626
from hathor.p2p.sync_v2.streamers import DEFAULT_STREAMING_LIMIT, StreamEnd
2727
from hathor.transaction import BaseTransaction
28-
from hathor.transaction.exceptions import HathorError
28+
from hathor.transaction.exceptions import HathorError, TxValidationError
2929
from hathor.types import VertexId
3030

3131
if TYPE_CHECKING:
@@ -93,12 +93,12 @@ def handle_transaction(self, tx: BaseTransaction) -> None:
9393
self.log.debug('tx received', tx_id=tx.hash.hex())
9494

9595
# Run basic verification.
96-
# if not tx.is_genesis:
97-
# try:
98-
# self.manager.verification_service.validate_basic(tx)
99-
# except TxValidationError as e:
100-
# self.fails(InvalidVertexError(repr(e)))
101-
# return
96+
if not tx.is_genesis:
97+
try:
98+
self.manager.verification_service.validate_basic(tx)
99+
except TxValidationError as e:
100+
self.fails(InvalidVertexError(repr(e)))
101+
return
102102

103103
# Any repeated transaction will fail this check because they will
104104
# not belong to the waiting list.

0 commit comments

Comments
 (0)