mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
f794438335
Code to support react based UI for diagnostics: * pprof, prometheus and diagnistics rationalized to use a single router (i.e. they can all run in the same port) * support_cmd updated to support node routing (was only first node) * Multi content support in router tunnel (application/octet-stream & appliaction/json) * Routing requests changed from using http forms to rest + query params * REST query requests can now be made against erigon base port and diagnostics with the same url format/params --------- Co-authored-by: dvovk <vovk.dimon@gmail.com> Co-authored-by: Mark Holt <mark@disributed.vision>
36 lines
893 B
Go
36 lines
893 B
Go
package diagnostics
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/ledgerwatch/erigon/dataflow"
|
|
)
|
|
|
|
func SetupHeaderDownloadStats(metricsMux *http.ServeMux) {
|
|
metricsMux.HandleFunc("/headers_download", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
|
writeHeaderDownload(w, r)
|
|
})
|
|
}
|
|
|
|
func writeHeaderDownload(w io.Writer, r *http.Request) {
|
|
if err := r.ParseForm(); err != nil {
|
|
fmt.Fprintf(w, "ERROR: parsing arguments: %v\n", err)
|
|
return
|
|
}
|
|
sinceTickStr := r.Form.Get("sincetick")
|
|
var tick int64
|
|
if sinceTickStr != "" {
|
|
var err error
|
|
if tick, err = strconv.ParseInt(sinceTickStr, 10, 64); err != nil {
|
|
fmt.Fprintf(w, "ERROR: parsing sincemilli: %v\n", err)
|
|
}
|
|
}
|
|
fmt.Fprintf(w, "SUCCESS\n")
|
|
// fmt.Fprintf(w, "%d,%d\n", p2p.ingressTrafficMeter, )
|
|
dataflow.HeaderDownloadStates.ChangesSince(int(tick), w)
|
|
}
|