erigon-pulse/cl/beacon/handler/genesis.go

33 lines
941 B
Go
Raw Normal View History

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"
"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"`
}
func (a *ApiHandler) getGenesis(r *http.Request) *beaconResponse {
if a.genesisCfg == nil {
return newApiErrorResponse(http.StatusNotFound, "Genesis Config is missing")
}
digest, err := fork.ComputeForkDigest(a.beaconChainCfg, a.genesisCfg)
if err != nil {
return newCriticalErrorResponse(err)
}
return newBeaconResponse(&genesisReponse{
GenesisTime: a.genesisCfg.GenesisTime,
GenesisValidatorRoot: a.genesisCfg.GenesisValidatorRoot,
GenesisForkVersion: digest,
})
}