github.com/ethereumproject/go-ethereum@v5.5.2+incompatible/eth/cpu_mining.go (about)

     1  // Copyright 2015 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  // +build !opencl
    18  
    19  package eth
    20  
    21  import (
    22  	"errors"
    23  	"fmt"
    24  
    25  	"github.com/ethereumproject/go-ethereum/logger"
    26  	"github.com/ethereumproject/go-ethereum/logger/glog"
    27  )
    28  
    29  const disabledInfo = "Set GO_OPENCL and re-build to enable."
    30  
    31  func (s *Ethereum) StartMining(threads int, gpus string) error {
    32  	eb, err := s.Etherbase()
    33  	if err != nil {
    34  		err = fmt.Errorf("Cannot start mining without etherbase address: %v", err)
    35  		glog.V(logger.Error).Infoln(err)
    36  		return err
    37  	}
    38  
    39  	if gpus != "" {
    40  		return errors.New("GPU mining disabled. " + disabledInfo)
    41  	}
    42  
    43  	// CPU mining
    44  	go s.miner.Start(eb, threads)
    45  	return nil
    46  }
    47  
    48  func GPUBench(gpuid uint64) {
    49  	fmt.Println("GPU mining disabled. " + disabledInfo)
    50  }
    51  
    52  func PrintOpenCLDevices() {
    53  	fmt.Println("OpenCL disabled. " + disabledInfo)
    54  }