Add 'keepalived' stratum method

This commit is contained in:
Sammy Libre 2017-09-24 00:43:26 +05:00
parent bf0ffb035f
commit eac8eb0228
3 changed files with 5 additions and 3 deletions

View File

@ -56,7 +56,7 @@ func (s *StratumServer) handleGetJobRPC(cs *Session, params *GetJobParams) (*Job
return cs.getJob(t), nil
}
func (s *StratumServer) handleSubmitRPC(cs *Session, params *SubmitParams) (*SubmitReply, *ErrorReply) {
func (s *StratumServer) handleSubmitRPC(cs *Session, params *SubmitParams) (*StatusReply, *ErrorReply) {
miner, ok := s.miners.Get(params.Id)
if !ok {
return nil, &ErrorReply{Code: -1, Message: "Unauthenticated"}
@ -89,7 +89,7 @@ func (s *StratumServer) handleSubmitRPC(cs *Session, params *SubmitParams) (*Sub
if !validShare {
return nil, &ErrorReply{Code: -1, Message: "Low difficulty share"}
}
return &SubmitReply{Status: "OK"}, nil
return &StatusReply{Status: "OK"}, nil
}
func (s *StratumServer) handleUnknownRPC(req *JSONRpcReq) *ErrorReply {

View File

@ -50,7 +50,7 @@ type JobReplyData struct {
Target string `json:"target"`
}
type SubmitReply struct {
type StatusReply struct {
Status string `json:"status"`
}

View File

@ -267,6 +267,8 @@ func (cs *Session) handleMessage(s *StratumServer, e *Endpoint, req *JSONRpcReq)
return cs.sendError(req.Id, errReply, false)
}
return cs.sendResult(req.Id, &reply)
case "keepalived":
return cs.sendResult(req.Id, &StatusReply{Status: "KEEPALIVED"})
default:
errReply := s.handleUnknownRPC(req)
return cs.sendError(req.Id, errReply, true)