2023-06-08 07:43:27 +00:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/ledgerwatch/erigon-lib/common"
|
2023-09-05 20:37:18 +00:00
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
2023-06-08 07:43:27 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cl/fork"
|
|
|
|
)
|
|
|
|
|
|
|
|
type genesisReponse struct {
|
2023-09-05 20:37:18 +00:00
|
|
|
GenesisTime uint64 `json:"genesis_time,omitempty"`
|
|
|
|
GenesisValidatorRoot common.Hash `json:"genesis_validator_root,omitempty"`
|
|
|
|
GenesisForkVersion libcommon.Bytes4 `json:"genesis_fork_version,omitempty"`
|
2023-06-08 07:43:27 +00:00
|
|
|
}
|
|
|
|
|
2023-11-22 00:45:15 +00:00
|
|
|
func (a *ApiHandler) getGenesis(r *http.Request) *beaconResponse {
|
2023-06-08 07:43:27 +00:00
|
|
|
if a.genesisCfg == nil {
|
2023-11-22 00:45:15 +00:00
|
|
|
return newApiErrorResponse(http.StatusNotFound, "Genesis Config is missing")
|
2023-06-08 07:43:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
digest, err := fork.ComputeForkDigest(a.beaconChainCfg, a.genesisCfg)
|
|
|
|
if err != nil {
|
2023-11-22 00:45:15 +00:00
|
|
|
return newCriticalErrorResponse(err)
|
2023-06-08 07:43:27 +00:00
|
|
|
}
|
|
|
|
|
2023-11-22 00:45:15 +00:00
|
|
|
return newBeaconResponse(&genesisReponse{
|
2023-06-08 07:43:27 +00:00
|
|
|
GenesisTime: a.genesisCfg.GenesisTime,
|
|
|
|
GenesisValidatorRoot: a.genesisCfg.GenesisValidatorRoot,
|
2023-09-01 13:29:17 +00:00
|
|
|
GenesisForkVersion: digest,
|
2023-11-22 00:45:15 +00:00
|
|
|
})
|
2023-06-08 07:43:27 +00:00
|
|
|
}
|