diff --git a/tools/tenscan/backend/obscuroscan_backend.go b/tools/tenscan/backend/obscuroscan_backend.go index 7c783d10c9..527a4669b3 100644 --- a/tools/tenscan/backend/obscuroscan_backend.go +++ b/tools/tenscan/backend/obscuroscan_backend.go @@ -30,6 +30,10 @@ func (b *Backend) GetLatestBatch() (*common.BatchHeader, error) { return b.obsClient.BatchHeaderByNumber(nil) } +func (b *Backend) GetTenNodeHealthStatus() (bool, error) { + return b.obsClient.Health() +} + func (b *Backend) GetLatestRollup() (*common.RollupHeader, error) { return &common.RollupHeader{}, nil } diff --git a/tools/tenscan/backend/webserver/webserver_routes_items.go b/tools/tenscan/backend/webserver/webserver_routes_items.go index 352d435a67..f0de58bfbc 100644 --- a/tools/tenscan/backend/webserver/webserver_routes_items.go +++ b/tools/tenscan/backend/webserver/webserver_routes_items.go @@ -17,6 +17,14 @@ func routeItems(r *gin.Engine, server *WebServer) { r.GET("/items/batches/", server.getBatchListing) r.GET("/items/blocks/", server.getBlockListing) r.GET("/info/obscuro/", server.getConfig) + r.POST("/info/health/", server.getHealthStatus) +} + +func (w *WebServer) getHealthStatus(c *gin.Context) { + healthStatus, err := w.backend.GetTenNodeHealthStatus() + + // TODO: error handling, since this does not easily tell connection errors from health errors + c.JSON(http.StatusOK, gin.H{"result": healthStatus, "errors": fmt.Sprintf("%s", err)}) } func (w *WebServer) getLatestBatch(c *gin.Context) {