@@ -507,6 +507,19 @@ def _update_log_direction(
507507 if self ._logs is None :
508508 return
509509
510+ self ._check_prev_production (address , slot , timestamp )
511+ self ._check_next_production (address , slot , timestamp )
512+ if self ._prev_log_exists and self ._next_log_exists :
513+ # _log_production is True when 2 out of 3 consecutive slots have
514+ # the same timestamp, otherwise it is False
515+ self ._log_production = (
516+ next_timestamp == timestamp and prev_timestamp != timestamp
517+ ) or (next_timestamp == prev_timestamp and next_timestamp != timestamp )
518+
519+ def _check_prev_production (
520+ self , address : int , slot : int , timestamp : datetime
521+ ) -> None :
522+ """Check the previous slot for production pulses."""
510523 prev_address , prev_slot = calc_log_address (address , slot , - 1 )
511524 if self ._log_exists (prev_address , prev_slot ):
512525 prev_timestamp = self ._logs [prev_address ][prev_slot ].timestamp
@@ -528,6 +541,10 @@ def _update_log_direction(
528541 elif self ._prev_log_exists :
529542 self ._prev_log_exists = False
530543
544+ def _check_next_production (
545+ self , address : int , slot : int , timestamp : datetime
546+ ) -> None :
547+ """Check the next slot for production pulses."""
531548 next_address , next_slot = calc_log_address (address , slot , 1 )
532549 if self ._log_exists (next_address , next_slot ):
533550 next_timestamp = self ._logs [next_address ][next_slot ].timestamp
@@ -549,13 +566,6 @@ def _update_log_direction(
549566 elif self ._next_log_exists :
550567 self ._next_log_exists = False
551568
552- if self ._prev_log_exists and self ._next_log_exists :
553- # _log_production is True when 2 out of 3 consecutive slots have
554- # the same timestamp, otherwise it is False
555- self ._log_production = (
556- next_timestamp == timestamp and prev_timestamp != timestamp
557- ) or (next_timestamp == prev_timestamp and next_timestamp != timestamp )
558-
559569 def _update_log_interval (self ) -> None :
560570 """Update the detected log interval based on the most recent two logs."""
561571 if self ._logs is None or self ._log_production is None :
0 commit comments