Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
26 lines
685 B
Go
26 lines
685 B
Go
package api
|
|
|
|
import "net/http"
|
|
|
|
type StrategyHandler struct {
|
|
hub *WSHub
|
|
}
|
|
|
|
func NewStrategyHandler(hub *WSHub) *StrategyHandler {
|
|
return &StrategyHandler{hub: hub}
|
|
}
|
|
|
|
func (h *StrategyHandler) PostRecompute(w http.ResponseWriter, r *http.Request) {
|
|
if h.hub == nil || h.hub.adaptiveEngine == nil {
|
|
http.Error(w, "adaptive strategy engine unavailable", http.StatusServiceUnavailable)
|
|
return
|
|
}
|
|
count, err := h.hub.adaptiveEngine.RecomputeAll()
|
|
if err != nil {
|
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
return
|
|
}
|
|
pushed := h.hub.PushAdaptiveStrategyUpdates()
|
|
writeJSON(w, map[string]interface{}{"success": true, "recomputed": count, "pushed": pushed})
|
|
}
|