@@ -462,6 +462,13 @@ let create_sync_status_observer ~logger ~is_seed ~demo_mode ~net
462
462
let open Mina_incremental.Status in
463
463
let restart_delay = Time.Span. of_min 5. in
464
464
let offline_shutdown_delay = Time.Span. of_min 25. in
465
+ let after_genesis =
466
+ let genesis_timestamp =
467
+ Genesis_constants. (
468
+ genesis_timestamp_of_string genesis_state_timestamp_string)
469
+ in
470
+ fun () -> Time. (( > = ) (now () )) genesis_timestamp
471
+ in
465
472
let incremental_status =
466
473
map4 online_status_incr transition_frontier_and_catchup_signal_incr
467
474
first_connection_incr first_message_incr
@@ -471,29 +478,31 @@ let create_sync_status_observer ~logger ~is_seed ~demo_mode ~net
471
478
else
472
479
match online_status with
473
480
| `Offline ->
474
- ( match ! next_helper_restart with
475
- | None ->
476
- next_helper_restart :=
477
- Some
478
- (Async.Clock.Event. run_after restart_delay
479
- (fun () ->
480
- [% log info]
481
- " Offline for too long; restarting libp2p_helper" ;
482
- Mina_networking. restart_helper net ;
483
- next_helper_restart := None ;
484
- match ! offline_shutdown with
485
- | None ->
486
- offline_shutdown :=
487
- Some
488
- (Async.Clock.Event. run_after
489
- offline_shutdown_delay
490
- (fun () -> raise Offline_shutdown )
491
- () )
492
- | Some _ ->
493
- () )
494
- () )
495
- | Some _ ->
496
- () ) ;
481
+ (* nothing to do if offline before genesis *)
482
+ ( if after_genesis () then
483
+ match ! next_helper_restart with
484
+ | None ->
485
+ next_helper_restart :=
486
+ Some
487
+ (Async.Clock.Event. run_after restart_delay
488
+ (fun () ->
489
+ [% log info]
490
+ " Offline for too long; restarting libp2p_helper" ;
491
+ Mina_networking. restart_helper net ;
492
+ next_helper_restart := None ;
493
+ match ! offline_shutdown with
494
+ | None ->
495
+ offline_shutdown :=
496
+ Some
497
+ (Async.Clock.Event. run_after
498
+ offline_shutdown_delay
499
+ (fun () -> raise Offline_shutdown )
500
+ () )
501
+ | Some _ ->
502
+ () )
503
+ () )
504
+ | Some _ ->
505
+ () ) ;
497
506
let is_empty = function `Empty -> true | _ -> false in
498
507
if is_empty first_connection then (
499
508
[% str_log info] Connecting ;
@@ -572,10 +581,12 @@ let create_sync_status_observer ~logger ~is_seed ~demo_mode ~net
572
581
| Some _ ->
573
582
()
574
583
| None ->
575
- bootstrap_timeout :=
576
- Some
577
- (Timeout. create () bootstrap_timeout_duration
578
- ~f: log_bootstrap_error_and_restart )
584
+ (* don't check bootstrap timeout before genesis *)
585
+ if after_genesis () then
586
+ bootstrap_timeout :=
587
+ Some
588
+ (Timeout. create () bootstrap_timeout_duration
589
+ ~f: log_bootstrap_error_and_restart )
579
590
in
580
591
let stop_bootstrap_timeout () =
581
592
match ! bootstrap_timeout with
@@ -585,7 +596,7 @@ let create_sync_status_observer ~logger ~is_seed ~demo_mode ~net
585
596
| None ->
586
597
()
587
598
in
588
- let handle_status_change sync_status =
599
+ let handle_status_change ( sync_status : Sync_status.t ) =
589
600
( match sync_status with
590
601
| `Offline ->
591
602
start_offline_timeout ()
0 commit comments