erigon-pulse/cmd/rpcdaemon/health/check_synced.go
hexoscott 423b4f68ac
use headers in rpc health check (#4639)
adding in unit tests for healthchecks
2022-07-06 09:43:22 +02:00

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
}