|
|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
package proxy |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"errors" |
|
|
|
|
"log" |
|
|
|
|
"regexp" |
|
|
|
|
"strings" |
|
|
|
|
@ -69,36 +68,30 @@ func (s *ProxyServer) handleSubmitRPC(cs *Session, login, id string, params []st
|
|
|
|
|
log.Printf("Malformed PoW result from %s@%s %v", login, cs.ip, params) |
|
|
|
|
return false, &ErrorReply{Code: -1, Message: "Malformed PoW result"} |
|
|
|
|
} |
|
|
|
|
go func(s *ProxyServer, cs *Session, login, id string, params []string) { |
|
|
|
|
t := s.currentBlockTemplate() |
|
|
|
|
exist, validShare := s.processShare(login, id, cs.ip, t, params) |
|
|
|
|
ok := s.policy.ApplySharePolicy(cs.ip, !exist && validShare) |
|
|
|
|
|
|
|
|
|
if exist { |
|
|
|
|
log.Printf("Duplicate share from %s@%s %v", login, cs.ip, params) |
|
|
|
|
cs.lastErr = errors.New("Duplicate share") |
|
|
|
|
return false, &ErrorReply{Code: 22, Message: "Duplicate share"} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if !validShare { |
|
|
|
|
log.Printf("Invalid share from %s@%s", login, cs.ip) |
|
|
|
|
// Bad shares limit reached, return error and close
|
|
|
|
|
if !ok { |
|
|
|
|
cs.lastErr = errors.New("Invalid share") |
|
|
|
|
return false, &ErrorReply{Code: 23, Message: "Invalid share"} |
|
|
|
|
} |
|
|
|
|
return false, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if s.config.Proxy.Debug { |
|
|
|
|
log.Printf("Valid share from %s@%s", login, cs.ip) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if !ok { |
|
|
|
|
cs.lastErr = errors.New("High rate of invalid shares") |
|
|
|
|
return true, &ErrorReply{Code: -1, Message: "High rate of invalid shares"} |
|
|
|
|
} |
|
|
|
|
}(s, cs, login, id, params) |
|
|
|
|
|
|
|
|
|
return true, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (s *ProxyServer) handleGetBlockByNumberRPC() *rpc.GetBlockReplyPart { |
|
|
|
|
t := s.currentBlockTemplate() |
|
|
|
|
var reply *rpc.GetBlockReplyPart |
|
|
|
|
|