Skip to content

Commit

Permalink
docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
msbrogli committed Nov 3, 2023
1 parent 38a762e commit 5b59091
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions hathor/p2p/sync_v2/blockchain_streaming_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,20 @@ def __init__(self, sync_agent: 'NodeBlockSync', start_block: '_HeightInfo', end_
self._partial_blocks: list[Block] = []

def wait(self) -> Deferred[StreamEnd]:
"""Return the deferred."""
return self._deferred

def fails(self, reason: 'StreamingError') -> None:
"""Fail the execution by resolving the deferred with an error."""
self._deferred.errback(reason)

def partial_vertex_exists(self, vertex_id: VertexId) -> bool:
""" Return true if the vertex exists no matter its validation state.
"""
"""Return true if the vertex exists no matter its validation state."""
with self.tx_storage.allow_partially_validated_context():
return self.tx_storage.transaction_exists(vertex_id)

def handle_blocks(self, blk: Block) -> None:
"""This method is called by the sync agent when a BLOCKS message is received."""
if self._deferred.called:
return

Expand Down Expand Up @@ -133,6 +135,7 @@ def handle_blocks(self, blk: Block) -> None:
self._partial_blocks.append(blk)

def handle_blocks_end(self, response_code: StreamEnd) -> None:
"""This method is called by the sync agent when a BLOCKS-END message is received."""
if self._deferred.called:
return
self._deferred.callback(response_code)
7 changes: 5 additions & 2 deletions hathor/p2p/sync_v2/transaction_streaming_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,20 @@ def __init__(self,
self._tx_max_quantity = DEFAULT_STREAMING_LIMIT

def wait(self) -> Deferred[StreamEnd]:
"""Return the deferred."""
return self._deferred

def fails(self, reason: 'StreamingError') -> None:
"""Fail the execution by resolving the deferred with an error."""
self._deferred.errback(reason)

def partial_vertex_exists(self, vertex_id: VertexId) -> bool:
""" Return true if the vertex exists no matter its validation state.
"""
"""Return true if the vertex exists no matter its validation state."""
with self.tx_storage.allow_partially_validated_context():
return self.tx_storage.transaction_exists(vertex_id)

def handle_transaction(self, tx: BaseTransaction) -> None:
"""This method is called by the sync agent when a TRANSACTION message is received."""
if self._deferred.called:
return

Expand Down Expand Up @@ -112,6 +114,7 @@ def handle_transaction(self, tx: BaseTransaction) -> None:
self.log.debug('tx streaming in progress', txs_received=self._tx_received)

def handle_transactions_end(self, response_code: StreamEnd) -> None:
"""This method is called by the sync agent when a TRANSACTIONS-END message is received."""
if self._deferred.called:
return
self._deferred.callback(response_code)

0 comments on commit 5b59091

Please sign in to comment.