@@ -503,8 +503,14 @@ def _update_log_direction(
503503 ) -> None :
504504 """Update Energy direction of log record.
505505
506- Two subsequential logs with the same timestamp indicates the first
507- is consumption and second production.
506+ Two subsequential logging slots with the same timestamp indicate
507+ both consumption and production logging is active.
508+ The first slot (e.g. 1) contains consumption data,
509+ the second slot (e.g. 2) production data.
510+
511+ This code expects either single slots containing consumption data
512+ or double slots containing consumption and production data.
513+ Single slots containing production data only is NOT supported/tested.
508514 """
509515 if self ._logs is None :
510516 return
@@ -513,10 +519,11 @@ def _update_log_direction(
513519 next_timestamp = self ._check_next_production (address , slot , timestamp )
514520 if self ._first_prev_log_processed and self ._first_next_log_processed :
515521 # _log_production is True when 2 out of 3 consecutive slots have
516- # the same timestamp, otherwise it is False
522+ # the same timestamp
517523 self ._log_production = (
518- next_timestamp == timestamp and prev_timestamp != timestamp
519- ) or (next_timestamp == prev_timestamp and next_timestamp != timestamp )
524+ (prev_timestamp == timestamp )
525+ ^ (next_timestamp == timestamp )
526+ )
520527
521528 def _check_prev_production (
522529 self , address : int , slot : int , timestamp : datetime
0 commit comments