diff --git a/stader/node/node.go b/stader/node/node.go index 373f1913..2d2f72de 100644 --- a/stader/node/node.go +++ b/stader/node/node.go @@ -404,19 +404,43 @@ func run(c *cli.Context) error { go func() { defer wg.Done() - privateKey, err := w.GetNodePrivateKey() - if err != nil { - errorLog.Printlnf("Error GetNodePrivateKey %+v", err) - return - } + for { - cfg, err := services.GetConfig(c) - if err != nil { - errorLog.Printlnf("Error getconfig %+v", err) - return - } + infoLog.Println("Start checking node diversity metrics") + // Check the EC status + err := services.WaitEthClientSynced(c, false) // Force refresh the primary / fallback EC status + if err != nil { + errorLog.Println(err) + time.Sleep(nodeDiversityTrackerCooldown) + + continue + } + + // Check the BC status + err = services.WaitBeaconClientSynced(c, false) // Force refresh the primary / fallback BC status + if err != nil { + errorLog.Println(err) + time.Sleep(nodeDiversityTrackerCooldown) + + continue + } + + privateKey, err := w.GetNodePrivateKey() + if err != nil { + errorLog.Printlnf("Error GetNodePrivateKey %+v", err) + time.Sleep(nodeDiversityTrackerCooldown) + + continue + } + + cfg, err := services.GetConfig(c) + if err != nil { + errorLog.Printlnf("Error getconfig %+v", err) + time.Sleep(nodeDiversityTrackerCooldown) + + continue + } - for { infoLog.Printlnf("Running the node diversity tracker daemon") message, err := makeNodeDiversityMessage(ec, bc, pnr, w, cfg) @@ -450,6 +474,7 @@ func run(c *cli.Context) error { errorLog.Println("Failed to send the NodeDiversity message with err: %s\n", response.Error) } + infoLog.Println("Done checking node diversity metrics") time.Sleep(nodeDiversityTracker) } }()