add comment; handle error on health check registration

This commit is contained in:
Dan Laine 2020-06-30 16:51:41 -04:00
parent 1be948f38c
commit d3a4dcffef
1 changed files with 4 additions and 1 deletions

View File

@ -507,7 +507,9 @@ func (n *Node) initHealthAPI() error {
}
n.Log.Info("initializing Health API")
service := health.NewService(n.Log)
service.RegisterHeartbeat("network.validators.heartbeat", n.Net, 5*time.Minute)
if err := service.RegisterHeartbeat("network.validators.heartbeat", n.Net, 5*time.Minute); err != nil {
return fmt.Errorf("couldn't register heartbeat health check: %w", err)
}
isBootstrappedFunc := func() (interface{}, error) {
pChainID, err := n.chainManager.Lookup("P")
if err != nil {
@ -529,6 +531,7 @@ func (n *Node) initHealthAPI() error {
}
return nil, nil
}
// Passes if the P, X and C chains are finished bootstrapping
if err := service.RegisterMonotonicCheckFunc("defaultChainsBootstrapped", isBootstrappedFunc); err != nil {
return err
}