From 557d03e1385bd186df75cee515a5f1d587c0c555 Mon Sep 17 00:00:00 2001 From: Chris Hager Date: Wed, 17 May 2023 21:01:55 +0200 Subject: [PATCH] persist validation errors in database (#413) save validation error --- services/api/service.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/api/service.go b/services/api/service.go index 3f7c3d74..cc47a653 100644 --- a/services/api/service.go +++ b/services/api/service.go @@ -1822,23 +1822,23 @@ func (api *RelayAPI) handleSubmitNewBlock(w http.ResponseWriter, req *http.Reque go api.processOptimisticBlock(opts) } else { // Simulate block (synchronously) - reqErr, simErr := api.simulateBlock(req.Context(), opts) // success/error logging happens inside + requestErr, validationErr = api.simulateBlock(req.Context(), opts) // success/error logging happens inside validationDurationMs := time.Since(timeBeforeValidation).Milliseconds() log = log.WithFields(logrus.Fields{ "timestampAfterValidation": time.Now().UTC().UnixMilli(), "validationDurationMs": validationDurationMs, }) - if reqErr != nil { // Request error - if os.IsTimeout(reqErr) { + if requestErr != nil { // Request error + if os.IsTimeout(requestErr) { api.RespondError(w, http.StatusGatewayTimeout, "validation request timeout") } else { - api.RespondError(w, http.StatusBadRequest, reqErr.Error()) + api.RespondError(w, http.StatusBadRequest, requestErr.Error()) } return } else { wasSimulated = true - if simErr != nil { - api.RespondError(w, http.StatusBadRequest, simErr.Error()) + if validationErr != nil { + api.RespondError(w, http.StatusBadRequest, validationErr.Error()) return } }