mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 12:07:17 +00:00
423b4f68ac
adding in unit tests for healthchecks
26 lines
406 B
Go
26 lines
406 B
Go
package health
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
|
|
"github.com/ledgerwatch/log/v3"
|
|
)
|
|
|
|
var (
|
|
errNotSynced = errors.New("not synced")
|
|
)
|
|
|
|
func checkSynced(ethAPI EthAPI, r *http.Request) error {
|
|
i, err := ethAPI.Syncing(r.Context())
|
|
if err != nil {
|
|
log.Root().Warn("unable to process synced request", "err", err.Error())
|
|
return err
|
|
}
|
|
if i == nil || i == false {
|
|
return nil
|
|
}
|
|
|
|
return errNotSynced
|
|
}
|