Skip to content

Commit

Permalink
multi: fix cpu miner stratum handshake.
Browse files Browse the repository at this point in the history
This updates the cpu miner stratum handshake
to only send an authorization request after the
subscription request has been processed.
  • Loading branch information
dnldd committed Jan 8, 2021
1 parent 1dfc4d4 commit 26db830
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
28 changes: 16 additions & 12 deletions cmd/miner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,23 +132,18 @@ func (m *Miner) keepAlive(ctx context.Context) {
m.conn = conn
m.encoder = json.NewEncoder(m.conn)
m.reader = bufio.NewReader(m.conn)
err = m.subscribe()
if err != nil {
log.Errorf("unable to subscribe miner: %v", err)
continue
}

err = m.authenticate()
if err != nil {
log.Errorf("unable to authenticate miner: %v", err)
continue
}
log.Debugf("miner connected to %s", poolAddr)

m.connectedMtx.Lock()
m.connected = true
m.connectedMtx.Unlock()

log.Debugf("miner connected to %s", poolAddr)
err = m.subscribe()
if err != nil {
log.Errorf("unable to subscribe miner: %v", err)
continue
}
}
}
}
Expand Down Expand Up @@ -264,12 +259,13 @@ func (m *Miner) process(ctx context.Context) {
}

if !status {
log.Error("unable to authorize request for miner")
log.Error("authorization request failed for miner")
m.cancel()
continue
}

m.authorized = true

log.Trace("Miner successfully authorized.")

case pool.Subscribe:
Expand All @@ -288,6 +284,14 @@ func (m *Miner) process(ctx context.Context) {
m.extraNonce2Size = extraNonce2Size
m.notifyID = notifyID
m.subscribed = true

err = m.authenticate()
if err != nil {
log.Errorf("unable to authenticate miner: %v", err)
m.cancel()
continue
}

log.Trace("Miner successfully subscribed.")

case pool.Submit:
Expand Down
4 changes: 2 additions & 2 deletions dcrpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func main() {
interrupt := make(chan os.Signal, 1)
signal.Notify(interrupt, os.Interrupt)

// Load configuration and parse command line. This also initializes logging
// and configures it accordingly.
// Load configuration and parse command line. This also initializes
// logging and configures it accordingly.
cfg, _, err := loadConfig()
if err != nil {
os.Exit(1)
Expand Down
4 changes: 2 additions & 2 deletions pool/chainstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (cs *ChainState) handleChainUpdates(ctx context.Context) {
// indicate an underlying issue accessing the
// database. The chainstate process will be
// terminated as a result.
log.Errorf("unable to prune hash rate: %v", err)
log.Errorf("unable to prune hash data: %v", err)
close(msg.Done)
cs.cfg.Cancel()
continue
Expand Down Expand Up @@ -291,7 +291,7 @@ func (cs *ChainState) handleChainUpdates(ctx context.Context) {
continue
}

// Signal the gui cache of the paid dividends.
// Signal the gui cache of paid dividends.
cs.cfg.SignalCache(DividendsPaid)

// Check if the parent of the connected block is an accepted work
Expand Down
4 changes: 2 additions & 2 deletions pool/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ type HubConfig struct {
DB Database
// NodeRPCConfig represents the mining node's RPC configuration details.
NodeRPCConfig *rpcclient.ConnConfig
// WalletRPPCCert represents the wallet's RPC certificate.
// WalletRPCCert represents the wallet's RPC certificate.
WalletRPCCert string
// WalletTLSCert represents the wallet client's TLS certificate.
WalletTLSCert string
Expand Down Expand Up @@ -716,7 +716,7 @@ func (h *Hub) FetchWorkQuotas() ([]*Quota, error) {
func (h *Hub) AccountExists(accountID string) bool {
_, err := h.cfg.DB.fetchAccount(accountID)
if err != nil {
log.Tracef("Unable to fetch account for id: %s", accountID)
log.Errorf("unable to fetch account for id: %s", accountID)
return false
}
return true
Expand Down

0 comments on commit 26db830

Please sign in to comment.