Fix Share stats disappearing regression
This commit is contained in:
6 files changed
+266
-2
No files matched your search
@@ -43,6 +43,7 @@ func (s *Server) Handler() http.Handler {
|
||||
mux.HandleFunc("POST /api/admin/reset-latency", s.resetLatency)
|
||||
mux.HandleFunc("POST /api/admin/ack-best", s.ackBest)
|
||||
mux.HandleFunc("POST /api/admin/reset-ack-best", s.resetAckBest)
|
||||
mux.HandleFunc("POST /api/admin/rebuild-share-stats", s.rebuildShareStats)
|
||||
mux.HandleFunc("POST /api/accelerate", s.accelerate)
|
||||
mux.HandleFunc("POST /api/accelerate/cancel", s.accelerateCancel)
|
||||
mux.HandleFunc("POST /api/accelerate/max", s.accelerateMax)
|
||||
@@ -223,6 +224,22 @@ func (s *Server) resetLatency(w http.ResponseWriter, _ *http.Request) {
|
||||
writeJSON(w, http.StatusOK, map[string]any{"ok": true})
|
||||
}
|
||||
|
||||
// rebuildShareStats recounts the all-time share statistics from the
|
||||
// ckpool log. Blocking and potentially slow (it reads the entire log),
|
||||
// so it is only ever reached by an explicit operator request.
|
||||
func (s *Server) rebuildShareStats(w http.ResponseWriter, _ *http.Request) {
|
||||
adopted, scanned, err := s.Agg.RebuildShareStatsFromLog()
|
||||
if err != nil {
|
||||
writeJSON(w, http.StatusInternalServerError, map[string]any{
|
||||
"ok": false, "error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"ok": true, "adopted": adopted, "shares_in_log": scanned,
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) ackBest(w http.ResponseWriter, _ *http.Request) {
|
||||
s.Agg.AckBestDiff()
|
||||
writeJSON(w, http.StatusOK, map[string]any{"ok": true})
|
||||
|
||||
Reference in new issue
Block a user