mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-07 03:22:18 +00:00
3c2b99e19c
we update observability in the p2p layer for handlers, and also properly encode error codes, close streams. --------- Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com> Co-authored-by: Giulio <giulio.rebuffo@gmail.com>
78 lines
2.0 KiB
Go
78 lines
2.0 KiB
Go
package beacon
|
|
|
|
import (
|
|
"net/http"
|
|
"sync"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
type ApiHandler struct {
|
|
o sync.Once
|
|
mux chi.Router
|
|
}
|
|
|
|
func (a *ApiHandler) init() {
|
|
r := chi.NewRouter()
|
|
a.mux = r
|
|
// This is the set of apis for validation + otterscan
|
|
// otterscn specific ones are commented as such
|
|
r.Route("/eth", func(r chi.Router) {
|
|
r.Route("/v1", func(r chi.Router) {
|
|
r.Get("/events", nil)
|
|
r.Route("/beacon", func(r chi.Router) {
|
|
r.Get("/headers/{tag}", nil) // otterscan
|
|
r.Get("/blocks/{slot}/root", nil) //otterscan
|
|
r.Get("/genesis", nil)
|
|
r.Post("/binded_blocks", nil)
|
|
r.Post("/blocks", nil)
|
|
r.Route("/pool", func(r chi.Router) {
|
|
r.Post("/attestations", nil)
|
|
r.Post("/sync_committees", nil)
|
|
})
|
|
r.Get("/node/syncing", nil)
|
|
r.Get("/config/spec", nil)
|
|
r.Route("/states", func(r chi.Router) {
|
|
r.Get("/head/validators/{index}", nil) // otterscan
|
|
r.Get("/head/committees", nil) // otterscan
|
|
r.Route("/{state_id}", func(r chi.Router) {
|
|
r.Get("/fork", nil)
|
|
r.Get("/validators/{id}", nil)
|
|
})
|
|
})
|
|
})
|
|
r.Route("/validator", func(r chi.Router) {
|
|
r.Route("/duties", func(r chi.Router) {
|
|
r.Post("/attester/{epoch}", nil)
|
|
r.Get("/proposer/{epoch}", nil)
|
|
r.Post("/sync/{epoch}", nil)
|
|
})
|
|
r.Get("blinded_blocks/{slot}", nil)
|
|
r.Get("attestation_data", nil)
|
|
r.Get("aggregate_attestation", nil)
|
|
r.Post("aggregate_and_proofs", nil)
|
|
r.Post("beacon_committee_subscriptions", nil)
|
|
r.Post("sync_committee_subscriptions", nil)
|
|
r.Get("sync_committee_contribution", nil)
|
|
r.Post("contribution_and_proofs", nil)
|
|
r.Post("prepare_beacon_proposer", nil)
|
|
})
|
|
})
|
|
r.Route("/v2", func(r chi.Router) {
|
|
r.Route("/beacon", func(r chi.Router) {
|
|
r.Post("/blocks/{slot}", nil) //otterscan
|
|
})
|
|
r.Route("/validator", func(r chi.Router) {
|
|
r.Post("/blocks/{slot}", nil)
|
|
})
|
|
})
|
|
})
|
|
}
|
|
|
|
func (a *ApiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
a.o.Do(func() {
|
|
a.init()
|
|
})
|
|
a.mux.ServeHTTP(w, r)
|
|
}
|