Skip to content

Commit

Permalink
Merge pull request #188 from stader-labs/wait_client_sync_node_divers…
Browse files Browse the repository at this point in the history
…ity_metrics

Wait client sync node diversity metrics
  • Loading branch information
batphonghan authored Feb 19, 2024
2 parents f8cdc8f + 58bae83 commit e914eb6
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions stader/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
}()
Expand Down

0 comments on commit e914eb6

Please sign in to comment.