erigon-pulse/diagnostics/snapshot_sync.go
Dmytro ff92b701c3
dvovk/updsync (#9134)
refactored data structure for sync statistics
2024-01-08 10:43:04 +01:00

19 lines
480 B
Go

package diagnostics
import (
"encoding/json"
"net/http"
)
func SetupStagesAccess(metricsMux *http.ServeMux, diag *DiagnosticClient) {
metricsMux.HandleFunc("/snapshot-sync", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Content-Type", "application/json")
writeStages(w, diag)
})
}
func writeStages(w http.ResponseWriter, diag *DiagnosticClient) {
json.NewEncoder(w).Encode(diag.SyncStatistics())
}