mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-26 01:39:26 +00:00
26 lines
423 B
Go
26 lines
423 B
Go
package health
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"net/http"
|
|
|
|
"github.com/ethereum/go-ethereum/log"
|
|
)
|
|
|
|
var (
|
|
errNotSynced = errors.New("not synced")
|
|
)
|
|
|
|
func checkSynced(ec ethClient, r *http.Request) error {
|
|
i, err := ec.SyncProgress(context.TODO())
|
|
if err != nil {
|
|
log.Root().Warn("Unable to check sync status for healthcheck", "err", err.Error())
|
|
return err
|
|
}
|
|
if i == nil {
|
|
return nil
|
|
}
|
|
|
|
return errNotSynced
|
|
}
|