Skip to content

Commit

Permalink
Remove excess log
Browse files Browse the repository at this point in the history
  • Loading branch information
bbedward committed May 29, 2023
1 parent 47198ab commit f7b3338
Showing 1 changed file with 0 additions and 14 deletions.
14 changes: 0 additions & 14 deletions controller/http_api_c.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request) {
return
}

klog.Infof("Received HTTP action %s", action)

// Trim count if it exists in action, so nobody can overload the node
if val, ok := baseRequest["count"]; ok {
countAsInt, err := strconv.ParseInt(fmt.Sprintf("%v", val), 10, 64)
Expand Down Expand Up @@ -146,7 +144,6 @@ func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request) {
if !ok {
jsonBlockStr, ok := baseRequest["json_block"].(string)
if !ok || (jsonBlockStr != "true" && jsonBlockStr != "false") {
klog.Error("json_block must be true or false")
ErrBadrequest(w, r, "json_block must be true or false")
return
}
Expand All @@ -163,18 +160,15 @@ func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request) {
var processRequestJsonBlock models.ProcessRequestJsonBlock
if jsonBlock {
if err := mapstructure.Decode(baseRequest, &processRequestJsonBlock); err != nil {
klog.Errorf("Error decoding process request %s", err)
ErrBadrequest(w, r, err.Error())
return
}
} else {
if err := mapstructure.Decode(baseRequest, &processRequestStringBlock); err != nil {
klog.Errorf("Error decoding process request string block %s", err)
ErrBadrequest(w, r, err.Error())
return
}
if err := json.Unmarshal([]byte(*processRequestStringBlock.Block), &processRequestBlock); err != nil {
klog.Errorf("Error unmarshal process request %s", err)
ErrBadrequest(w, r, err.Error())
return
}
Expand All @@ -187,7 +181,6 @@ func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request) {
}

if processRequestJsonBlock.Block.Type != "state" {
klog.Errorf("Only state blocks are supported")
ErrBadrequest(w, r, "Only state blocks are supported")
return
}
Expand All @@ -205,7 +198,6 @@ func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request) {
processRequestJsonBlock.SubType = &subtype
}
} else if !slices.Contains([]string{"change", "open", "receive", "send"}, *processRequestJsonBlock.SubType) {
klog.Errorf("Invalid subtype %s", *processRequestJsonBlock.SubType)
ErrBadrequest(w, r, fmt.Sprintf("Invalid subtype %s", *processRequestJsonBlock.SubType))
return
}
Expand All @@ -218,7 +210,6 @@ func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request) {
if processRequestJsonBlock.Block.Previous == "0" || processRequestJsonBlock.Block.Previous == "0000000000000000000000000000000000000000000000000000000000000000" {
workbaseBytes, err := utils.AddressToPub(processRequestJsonBlock.Block.Account)
if err != nil {
klog.Errorf("Error converting address to public key %s", err)
ErrBadrequest(w, r, err.Error())
return
}
Expand All @@ -237,7 +228,6 @@ func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request) {
if _, ok := accountInfo["error"]; !ok {
// Account is opened
if strings.ToLower(fmt.Sprintf("%s", accountInfo["frontier"])) != strings.ToLower(processRequestJsonBlock.Block.Previous) {
klog.Errorf("Invalid frontier %s", processRequestJsonBlock.Block.Previous)
ErrBadrequest(w, r, err.Error())
return
}
Expand All @@ -257,20 +247,17 @@ func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request) {
difficultyMultiplier = 1
}
if doWork {
klog.Infof("Generating work for %s", workBase)
work, err := hc.RPCClient.WorkGenerate(workBase, difficultyMultiplier)
if err != nil {
klog.Errorf("Error generating work %s", err)
ErrInternalServerError(w, r, "Error generating work")
return
}
klog.Infof("Work generated %s", work)
processRequestJsonBlock.Block.Work = &work
}
}

if processRequestJsonBlock.Block.Work == nil {
klog.Errorf("Work is required")
ErrInvalidRequest(w, r)
return
}
Expand All @@ -297,7 +284,6 @@ func (hc *HttpController) HandleAction(w http.ResponseWriter, r *http.Request) {
ErrInternalServerError(w, r, "Error unmarshalling response")
return
}
klog.Infof("Successfully processed block %s", responseMap["hash"])
render.Status(r, http.StatusOK)
render.JSON(w, r, responseMap)
return
Expand Down

0 comments on commit f7b3338

Please sign in to comment.