diff --git a/cpuminer.go b/cpuminer.go index a45e70ee..1e473349 100644 --- a/cpuminer.go +++ b/cpuminer.go @@ -548,14 +548,6 @@ func (m *CPUMiner) NumWorkers() int32 { func (m *CPUMiner) GenerateNBlocks(n uint32) ([]*chainhash.Hash, error) { m.Lock() - // Respond with an error if there's virtually 0 chance of CPU-mining a block. - if !m.cfg.ChainParams.GenerateSupported { - m.Unlock() - return nil, errors.New("No support for `generate` on the current " + - "network, " + m.cfg.ChainParams.Net.String() + - ", as it's unlikely to be possible to CPU-mine a block.") - } - // Respond with an error if server is already mining. if m.started || m.discreteMining { m.Unlock() diff --git a/rpcserver.go b/rpcserver.go index 74f8b8e4..5c5547aa 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -856,6 +856,19 @@ func handleGenerate(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (i } } + // Respond with an error if there's virtually 0 chance of mining a block + // with the CPU. + params := s.server.chainParams + if !s.server.chainParams.GenerateSupported { + return nil, &btcjson.RPCError{ + Code: btcjson.ErrRPCDifficulty, + Message: fmt.Sprintf("No support for `generate` on "+ + "the current network, %s, as it's unlikely to "+ + "be possible to main a block with the CPU.", + params.Net), + } + } + c := cmd.(*btcjson.GenerateCmd) // Respond with an error if the client is requesting 0 blocks to be generated.