Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: add status endpoint from tendermint #1175

Merged
merged 9 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/gRPC/gRPC.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
eventRecordList = "/clerk/event-record/list"
fetchCheckpointCount = "/checkpoints/count"
fetchCheckpoint = "/checkpoints/%s"
fetchMilestoneCount = "/checkpoints/count"
fetchMilestoneCount = "/milestone/count"
fetchMilestone = "/milestone/latest"
fetchMilestoneNoAck = "/milestone/noAck/%s"
fetchLastNoAckMilestone = "/milestone/lastNoAck"
Expand Down
17 changes: 17 additions & 0 deletions server/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/go-kit/log"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
Expand All @@ -26,6 +27,7 @@ import (
"github.com/maticnetwork/heimdall/app"
tx "github.com/maticnetwork/heimdall/client/tx"
"github.com/maticnetwork/heimdall/helper"
hmRest "github.com/maticnetwork/heimdall/types/rest"

// unnamed import of statik for swagger UI support
"github.com/maticnetwork/heimdall/server/gRPC"
Expand Down Expand Up @@ -264,6 +266,9 @@ func RegisterRoutes(ctx client.CLIContext, mux *mux.Router) {
rpc.RegisterRPCRoutes(ctx, mux)
tx.RegisterRoutes(ctx, mux)

// Register the sync info endpoint here (as it's generic)
mux.HandleFunc("/sync_info", syncInfoHandlerFn(ctx)).Methods("GET")

// auth.RegisterRoutes(rs.CliCtx, rs.Mux)
// bank.RegisterRoutes(rs.CliCtx, rs.Mux)

Expand All @@ -285,3 +290,15 @@ func registerSwaggerUI(mux *mux.Router) {
staticServer := http.FileServer(statikFS)
mux.PathPrefix("/swagger-ui/").Handler(http.StripPrefix("/swagger-ui/", staticServer))
}

func syncInfoHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
status, err := cliCtx.Client.Status()
if err != nil {
hmRest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}

rest.PostProcessResponse(w, cliCtx, status.SyncInfo)
}
}
Loading