From eac8eb02288f42a54c6ca095e7949c728d2e10bf Mon Sep 17 00:00:00 2001 From: Sammy Libre Date: Sun, 24 Sep 2017 00:43:26 +0500 Subject: [PATCH] Add 'keepalived' stratum method --- stratum/handlers.go | 4 ++-- stratum/proto.go | 2 +- stratum/stratum.go | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/stratum/handlers.go b/stratum/handlers.go index c7ff1a5..ebf4880 100644 --- a/stratum/handlers.go +++ b/stratum/handlers.go @@ -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 { diff --git a/stratum/proto.go b/stratum/proto.go index e3963b3..0be91c6 100644 --- a/stratum/proto.go +++ b/stratum/proto.go @@ -50,7 +50,7 @@ type JobReplyData struct { Target string `json:"target"` } -type SubmitReply struct { +type StatusReply struct { Status string `json:"status"` } diff --git a/stratum/stratum.go b/stratum/stratum.go index 5097a1b..670706e 100644 --- a/stratum/stratum.go +++ b/stratum/stratum.go @@ -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)