Browse Source

return

master
yuriy0803 2 years ago
parent
commit
0ee1bb8b0b
  1. 15
      proxy/handlers.go
  2. 7
      proxy/stratum.go

15
proxy/handlers.go

@ -1,7 +1,6 @@
package proxy
import (
"fmt"
"log"
"regexp"
"strings"
@ -174,10 +173,10 @@ func (s *ProxyServer) handleGetBlockByNumberRPC() *rpc.GetBlockReplyPart {
return reply
}
// handleUnknownRPC handles incoming requests with unknown methods
func (s *ProxyServer) handleUnknownRPC(cs *Session, method string) *ErrorReply {
// Implement your logic for handling unknown methods here
// For example, you can return a custom error indicating that the method is not supported
errMsg := fmt.Sprintf("Method %s not supported", method)
return &ErrorReply{Code: -32601, Message: errMsg}
}
// handleUnknownRPC handles an unknown RPC request method.
// It logs an error and returns an error reply.
func (s *ProxyServer) handleUnknownRPC(cs *Session, m string) *ErrorReply {
log.Printf("Unknown request method %s from %s", m, cs.ip)
s.policy.ApplyMalformedPolicy(cs.ip)
return &ErrorReply{Code: -3, Message: "Method not found"}
}

7
proxy/stratum.go

@ -5,7 +5,6 @@ import (
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io"
"log"
"math/rand"
@ -393,12 +392,8 @@ func (cs *Session) handleTCPMessage(s *ProxyServer, req *StratumReq) error {
return cs.sendTCPResult(req.Id, &reply)
case "eth_submitHashrate":
// Return an error indicating that the method is not supported
errMsg := fmt.Sprintf("Method %s not supported", req.Method)
errReply := &ErrorReply{Code: -32601, Message: errMsg}
return cs.sendTCPError(req.Id, errReply)
return cs.sendTCPResult(req.Id, true)
default:
// Handle unknown methods
errReply := s.handleUnknownRPC(cs, req.Method)
return cs.sendTCPError(req.Id, errReply)
}

Loading…
Cancel
Save