""" Calculate mining rewards and probabilities for pool mining with multiple machines """ import math import logging from typing import Dict def calculate_pool_mining_stats( hash_rate_per_core: float, # Your hash rate per core cores_per_machine: int, # Number of cores per machine num_machines: int, # Number of machines in your pool network_hashrate: float = 400e18, # Current Bitcoin network hash rate (~400 EH/s) block_reward: float = 6.25, # Current block reward block_time: int = 600, # Target block time in seconds (10 minutes) pool_fee: float = 0.02 # Pool fee (2%) ) -> Dict: """ Calculate mining statistics for a pool of machines """ # Calculate total hash rate for your operation your_hashrate = hash_rate_per_core * cores_per_machine * num_machines # Calculate your share of the network (as a percentage) network_share = (your_hashrate / network_hashrate) * 100 # Calculate expected blocks per day across entire network blocks_per_day = (24 * 60 * 60) / block_time # 144 blocks per day # Calculate your expected blocks per day based on your share your_blocks_per_day = blocks_per_day * (network_share / 100) # Calculate daily BTC reward before pool fee daily_btc_reward = your_blocks_per_day * block_reward # Calculate daily BTC reward after pool fee daily_btc_reward_after_fee = daily_btc_reward * (1 - pool_fee) # Calculate efficiency metrics btc_per_machine_per_day = daily_btc_reward_after_fee / num_machines hashrate_th_per_machine = (hash_rate_per_core * cores_per_machine) / 1e12 # Convert to TH/s return { "total_hashrate": your_hashrate, "hashrate_th": your_hashrate / 1e12, # Convert to TH/s "network_share_percent": network_share, "expected_blocks_per_day": your_blocks_per_day, "daily_btc_reward": daily_btc_reward_after_fee, "btc_per_machine_per_day": btc_per_machine_per_day, "hashrate_th_per_machine": hashrate_th_per_machine } def log_pool_stats(stats: Dict, btc_price_usd: float = 28000): """ Log pool mining statistics in a human-readable format """ logging.info("\n=== Pool Mining Statistics ===") logging.info(f"Total Hash Rate: {stats['hashrate_th']:.2f} TH/s") logging.info(f"Hash Rate per Machine: {stats['hashrate_th_per_machine']:.2f} TH/s") logging.info(f"Network Share: {stats['network_share_percent']:.8f}%") logging.info(f"Expected Blocks per Day: {stats['expected_blocks_per_day']:.4f}") logging.info(f"Daily BTC Reward (after pool fee): {stats['daily_btc_reward']:.8f} BTC") logging.info(f"Daily USD Value: ${stats['daily_btc_reward'] * btc_price_usd:,.2f}") logging.info(f"BTC per Machine per Day: {stats['btc_per_machine_per_day']:.8f} BTC") logging.info(f"USD per Machine per Day: ${stats['btc_per_machine_per_day'] * btc_price_usd:,.2f}") logging.info("===========================\n") # Example usage if __name__ == "__main__": # Your current setup parameters HASH_RATE_PER_CORE = 7.3e6 # 7.3M hashes per core CORES_PER_MACHINE = 8 # Assuming 8 cores per machine NUM_MACHINES = 100 # Example: 100 machines stats = calculate_pool_mining_stats( hash_rate_per_core=HASH_RATE_PER_CORE, cores_per_machine=CORES_PER_MACHINE, num_machines=NUM_MACHINES ) log_pool_stats(stats)