@@ -40,17 +40,12 @@ def __init__(self, ctx: DipDupContext, config: ResolvedIndexConfigT, datasource:
4040 self ._datasource = datasource
4141
4242 self ._logger = FormattedLogger ('dipdup.index' , fmt = f'{ config .name } : ' + '{}' )
43- self ._head : Optional [models .Head ] = None
4443 self ._state : Optional [models .Index ] = None
4544
4645 @property
4746 def datasource (self ) -> TzktDatasource :
4847 return self ._datasource
4948
50- @property
51- def head (self ) -> Optional [models .Head ]:
52- return self ._head
53-
5449 @property
5550 def state (self ) -> models .Index :
5651 if self ._state is None :
@@ -124,6 +119,7 @@ async def _enter_sync_state(self, last_level: int) -> Optional[int]:
124119
125120 async def _exit_sync_state (self , last_level : int ) -> None :
126121 self ._logger .info ('Index is synchronized to level %s' , last_level )
122+ # NOTE: No head yet, wait for realtime messages to be processed
127123 await self .state .update_status (IndexStatus .REALTIME , last_level )
128124
129125
@@ -231,9 +227,11 @@ async def _process_level_operations(self, level: int, operations: List[Operation
231227 self ._logger .info ('Processing %s operations of level %s' , len (operations ), level )
232228 await self ._process_operations (operations )
233229
234- status = IndexStatus .REALTIME if block else IndexStatus .SYNCING
235- # FIXME: Not obvious: receiving `BlockData`, sending `Head`
236- await self .state .update_status (status , level , self .head if block else None )
230+ if block :
231+ status , head = IndexStatus .REALTIME , self .datasource .head
232+ else :
233+ status , head = IndexStatus .SYNCING , None
234+ await self .state .update_status (status , level , head )
237235
238236 async def _match_operation (self , pattern_config : OperationHandlerPatternConfigT , operation : OperationData ) -> bool :
239237 """Match single operation with pattern"""
@@ -459,8 +457,11 @@ async def _process_level_big_maps(self, level: int, big_maps: List[BigMapData],
459457 self ._logger .info ('Processing %s big map diffs of level %s' , len (big_maps ), level )
460458 await self ._process_big_maps (big_maps )
461459
462- status = IndexStatus .REALTIME if block else IndexStatus .SYNCING
463- await self .state .update_status (status , level , self .datasource .block if block else None )
460+ if block :
461+ status , head = IndexStatus .REALTIME , self .datasource .head
462+ else :
463+ status , head = IndexStatus .SYNCING , None
464+ await self .state .update_status (status , level , head )
464465
465466 async def _match_big_map (self , handler_config : BigMapHandlerConfig , big_map : BigMapData ) -> bool :
466467 """Match single big map diff with pattern"""
0 commit comments