CMSwitcher is a CPU mining profitability switcher that automatically benchmarks and switches between different mining algorithms based on real-time profitability calculations. It works with cpuminer-opt or cpuminer-multi.
- Automatic Benchmarking: Tests all supported algorithm combinations between miners and pools
- Real-time Profit Switching: Monitors profitability and automatically switches to the most profitable algorithm
- Multi-pool Support: Works with multiple mining pools simultaneously
- Configurable Parameters: Customizable benchmark periods, profit thresholds, and session timeouts
- Robust Error Handling: Handles network failures, miner crashes, and API issues gracefully
- Detailed Logging: Comprehensive logging with configurable levels
- Python 3.7+
- cpuminer-opt or cpuminer-multi binary
- Internet connection for pool APIs and Bitcoin price data
- Clone the repository:
git clone https://github.com/yourusername/cmswitcher.git
cd cmswitcher
- Install dependencies:
pip install -r requirements.txt
- Configure your settings in the
data/
directory:config.json
: General settings and thresholdsminers.json
: Miner configurationspools.json
: Pool settings and credentialsalgos.json
: Algorithm name mappings
python cmswitcher.py --cpuminer /path/to/cpuminer
python cmswitcher.py --help
Options:
--cpuminer PATH Path to cpuminer binary (default: cpuminer)
--data-dir PATH Data directory with config files (default: ./data)
--log-level LEVEL Logging level: DEBUG, INFO, WARNING, ERROR (default: INFO)
--log-file PATH Log to file (optional)
--benchmark-only Run benchmarks only, don't start mining
--force-benchmark Force re-run all benchmarks
# Run with specific cpuminer binary
python cmswitcher.py --cpuminer "C:/miners/cpuminer-avx2.exe"
# Run with debug logging
python cmswitcher.py --cpuminer cpuminer --log-level DEBUG
# Benchmark only mode
python cmswitcher.py --cpuminer cpuminer --benchmark-only
# Force re-benchmark all algorithms
python cmswitcher.py --cpuminer cpuminer --force-benchmark
{
"benchmark_period": 120, # Benchmark duration in seconds
"complete_benchmark_min_shares": 100, # Minimum shares for valid benchmark
"give_up_benchmark_low_profit_secs": 30, # Give up on unprofitable algos
"min_profit": 0.05, # Minimum profit threshold (USD/day)
"max_rejected_shares": 2, # Max rejected shares during benchmark
"session_timeout": 600, # Mining session duration in seconds
"blacklisted_algos": ["sha256", "scrypt"] # Algorithms to skip
}
{
"zergpool": {
"wallet": "YOUR_BTC_ADDRESS",
"password": "c=BTC",
"mine_url": "stratum+tcp://{algo}.mine.zergpool.com",
"api": "https://api.zergpool.com/api/status"
}
}
{
"cpuminer-opt": {
"launch_pattern": "-o {url}:{port} -u {wallet} -p {password} --api-bind={API_HOST}:{API_PORT}",
"offline_bench": "--benchmark",
"std_algos": ["yescrypt", "yespower", "argon2d"],
"custom_algos": {}
}
}
The application is organized into modular components:
cmswitcher/config.py
: Configuration managementcmswitcher/models.py
: Data models (Miner, Pool, BenchmarkResult)cmswitcher/api_client.py
: cpuminer API communicationcmswitcher/pool_api.py
: Pool API interactioncmswitcher/benchmark.py
: Benchmarking logiccmswitcher/profit.py
: Profitability calculationscmswitcher/mining_session.py
: Mining process managementcmswitcher/main.py
: Application orchestration
- Initialization: Loads configuration and discovers supported algorithms
- Benchmarking: Tests each algorithm to determine hashrates
- Profit Calculation: Fetches current pool rates and Bitcoin price
- Mining Loop:
- Finds most profitable algorithm
- Starts mining session
- Monitors performance and profitability
- Switches when a better option becomes available
The application will use a default Bitcoin price ($40,000) if it cannot fetch current prices.
The application automatically detects crashed miners and restarts with a different algorithm.
Adjust the min_profit
threshold in config.json
to match your expectations.
This project is licensed under the MIT License - see the LICENSE file for details.