Skip to content

Commit

Permalink
Fix a bug with looping on a single block
Browse files Browse the repository at this point in the history
  • Loading branch information
hweawer committed Sep 4, 2024
1 parent 54ba420 commit f9796fc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/transport/msg_providers/onchain_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,12 @@ def _construct_parsers(self, sinks: List[OnchainTransportSinks]) -> List[EventPa
def _fetch_messages(self) -> List[Any]:
latest_block_number = self._w3.eth.block_number
from_block = max(0, latest_block_number - self.STANDARD_OFFSET) if self._latest_block == -1 else self._latest_block

# If block distance is 0, then skip fetching to avoid looping on a single block
if from_block == latest_block_number:
return []
filter_params = FilterParams(
fromBlock=from_block,
toBlock=latest_block_number,
address=self._onchain_address,
topics=[self._topics],
)
Expand Down

0 comments on commit f9796fc

Please sign in to comment.