mirror of
https://github.com/cryptonote-social/csminer.git
synced 2024-09-11 05:35:23 +03:00
exit mining if pool server returns login error
This commit is contained in:
parent
3571b0cbf4
commit
ab044e4287
6
miner.go
6
miner.go
@ -200,6 +200,11 @@ func connectClient(cl *client.Client, uname, rigid string, startDiff int, config
|
||||
err := cl.Connect(uname, config, rigid, useTLS)
|
||||
clMutex.Unlock()
|
||||
if err != nil {
|
||||
errString := err.Error()
|
||||
if strings.Index(errString, client.STRATUM_SERVER_ERROR) == 0 {
|
||||
crylog.Error("Pool server returned error:", errString[len(client.STRATUM_SERVER_ERROR):])
|
||||
os.Exit(1)
|
||||
}
|
||||
crylog.Warn("Client failed to connect:", err)
|
||||
time.Sleep(sleepSec)
|
||||
sleepSec += time.Second
|
||||
@ -215,6 +220,7 @@ func connectClient(cl *client.Client, uname, rigid string, startDiff int, config
|
||||
err := cl.DispatchJobs()
|
||||
if err != nil {
|
||||
crylog.Error("Job dispatcher exitted with error:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
clMutex.Lock()
|
||||
if clientAlive {
|
||||
|
@ -22,6 +22,8 @@ const (
|
||||
CONNECT_JSON_ID = 666
|
||||
|
||||
MAX_REQUEST_SIZE = 10000 // Max # of bytes we will read per request
|
||||
|
||||
STRATUM_SERVER_ERROR = "stratum server error: "
|
||||
)
|
||||
|
||||
type Job struct {
|
||||
@ -70,6 +72,9 @@ func NewClient(address string, agent string) *Client {
|
||||
}
|
||||
}
|
||||
|
||||
// Connect to the stratum server port with the given login info. Returns error if connection could
|
||||
// not be established, or if the stratum server itself returned an error. The later case is
|
||||
// indicated by an error string prefix of STRATUM_SERVER_ERROR.
|
||||
func (cl *Client) Connect(uname, pw, rigid string, useTLS bool) error {
|
||||
var err error
|
||||
if !useTLS {
|
||||
@ -137,7 +142,7 @@ func (cl *Client) Connect(uname, pw, rigid string, useTLS bool) error {
|
||||
}
|
||||
if response.Result == nil {
|
||||
crylog.Error("Didn't get job result from login response:", response.Error)
|
||||
return errors.New("pool server returned error: " + response.Error.Message)
|
||||
return errors.New(STRATUM_SERVER_ERROR + response.Error.Message)
|
||||
}
|
||||
crylog.Info("login response:", response)
|
||||
cl.firstJob = response.Result.Job
|
||||
|
Loading…
Reference in New Issue
Block a user