|
|
"""
|
|
|
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,
|
|
|
cores_per_machine: int,
|
|
|
num_machines: int,
|
|
|
network_hashrate: float = 400e18,
|
|
|
block_reward: float = 6.25,
|
|
|
block_time: int = 600,
|
|
|
pool_fee: float = 0.02
|
|
|
) -> Dict:
|
|
|
"""
|
|
|
Calculate mining statistics for a pool of machines
|
|
|
"""
|
|
|
|
|
|
your_hashrate = hash_rate_per_core * cores_per_machine * num_machines
|
|
|
|
|
|
|
|
|
network_share = (your_hashrate / network_hashrate) * 100
|
|
|
|
|
|
|
|
|
blocks_per_day = (24 * 60 * 60) / block_time
|
|
|
|
|
|
|
|
|
your_blocks_per_day = blocks_per_day * (network_share / 100)
|
|
|
|
|
|
|
|
|
daily_btc_reward = your_blocks_per_day * block_reward
|
|
|
|
|
|
|
|
|
daily_btc_reward_after_fee = daily_btc_reward * (1 - pool_fee)
|
|
|
|
|
|
|
|
|
btc_per_machine_per_day = daily_btc_reward_after_fee / num_machines
|
|
|
hashrate_th_per_machine = (hash_rate_per_core * cores_per_machine) / 1e12
|
|
|
|
|
|
return {
|
|
|
"total_hashrate": your_hashrate,
|
|
|
"hashrate_th": your_hashrate / 1e12,
|
|
|
"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")
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
HASH_RATE_PER_CORE = 7.3e6
|
|
|
CORES_PER_MACHINE = 8
|
|
|
NUM_MACHINES = 100
|
|
|
|
|
|
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)
|
|
|
|