From d4beb08fd8d6216f4254d10cd56470ef5a445a1a Mon Sep 17 00:00:00 2001 From: cyc60 Date: Mon, 18 Nov 2024 15:21:58 +0300 Subject: [PATCH] Add chunk comments --- sw_utils/event_scanner.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sw_utils/event_scanner.py b/sw_utils/event_scanner.py index 9b479ac..18e55b6 100644 --- a/sw_utils/event_scanner.py +++ b/sw_utils/event_scanner.py @@ -58,8 +58,11 @@ def __init__( self._contract_call = lambda from_block, to_block: getattr( processor.contract.events, processor.contract_event ).get_logs(argument_filters=argument_filters, fromBlock=from_block, toBlock=to_block) - # Scan in chunks, commit between - self.chunk_size = chunk_size or self.max_scan_chunk_size // 2 + + # Start with half or max chunk size. 1kk chunks works only with powerful nodes. + start_chunk_size = self.max_scan_chunk_size // 2 + # Scan in chunks, commit between. + self.chunk_size = chunk_size or start_chunk_size async def process_new_events(self, to_block: BlockNumber) -> None: current_from_block = await self.processor.get_from_block()