Browse Source

Update stratum.go

master
yuriy0803 3 years ago committed by GitHub
parent
commit
f2dd4b1f3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      proxy/stratum.go

33
proxy/stratum.go

@ -326,18 +326,27 @@ func (cs *Session) handleTCPMessage(s *ProxyServer, req *StratumReq) error {
return cs.sendTCPError(req.Id, errReply) return cs.sendTCPError(req.Id, errReply)
} }
return cs.sendTCPResult(req.Id, &reply) return cs.sendTCPResult(req.Id, &reply)
case "eth_submitWork": // Handle requests of type "eth_submitWork"
var params []string case "eth_submitWork":
err := json.Unmarshal(req.Params, &params) // Unmarshal the parameters from the request into a slice of strings
if err != nil || len(params) < 3 { var params []string
log.Println("Malformed stratum request params from", cs.ip) err := json.Unmarshal(req.Params, &params)
return err // Check if there was an error unmarshaling the parameters or if they don't meet the required length and format criteria
} if err != nil || len(params) < 3 || len(params[0]) != 18 || len(params[1]) != 66 || len(params[2]) != 66 {
reply, errReply := s.handleTCPSubmitRPC(cs, req.Worker, params) // If there was an error, log the issue and return it
if errReply != nil { log.Println("Malformed stratum request params from", cs.ip)
return cs.sendTCPError(req.Id, errReply) return err
} }
return cs.sendTCPResult(req.Id, &reply) // If the parameters are valid, call the handler function for submitting work
reply, errReply := s.handleTCPSubmitRPC(cs, req.Worker, params)
// Check if there was an error handling the request
if errReply != nil {
// If there was, return the error
return cs.sendTCPError(req.Id, errReply)
}
// If the request was handled successfully, return the result
return cs.sendTCPResult(req.Id, &reply)
case "eth_submitHashrate": case "eth_submitHashrate":
return cs.sendTCPResult(req.Id, true) return cs.sendTCPResult(req.Id, true)
default: default:

Loading…
Cancel
Save