stratum - submit all blocks option. cleanup

This commit is contained in:
Dobromir Popov
2025-09-23 13:27:27 +03:00
parent 44d6d91103
commit 4743ee4369
10 changed files with 27 additions and 1592 deletions

View File

@@ -18,7 +18,8 @@ class RinCoinStratumProxy:
def __init__(self, stratum_host='0.0.0.0', stratum_port=3334,
rpc_host='127.0.0.1', rpc_port=9556,
rpc_user='rinrpc', rpc_password='745ce784d5d537fc06105a1b935b7657903cfc71a5fb3b90',
target_address='rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q'):
target_address='rin1qahvvv9d5f3443wtckeqavwp9950wacxfmwv20q',
submit_all_blocks=False):
self.stratum_host = stratum_host
self.stratum_port = stratum_port
@@ -27,6 +28,7 @@ class RinCoinStratumProxy:
self.rpc_user = rpc_user
self.rpc_password = rpc_password
self.target_address = target_address
self.submit_all_blocks = submit_all_blocks # If True, submit even invalid blocks for testing
self.clients = {}
self.job_counter = 0
@@ -406,8 +408,8 @@ class RinCoinStratumProxy:
diff1_target = 0x00000000FFFF0000000000000000000000000000000000000000000000000000
optimal_difficulty = (estimated_hashrate * diff1_target) / (target_shares_per_second * (2**256))
# More practical approach: start with network difficulty scaled down
optimal_difficulty = max(network_diff * 0.001, 0.0001) # 0.1% of network, min 0.0001
# More practical approach: start with network difficulty scaled way down for solo mining
optimal_difficulty = max(network_diff * 0.00001, 0.000001) # 0.001% of network, min 0.000001
print(f" 📊 New client {addr}: Network diff {network_diff:.6f}, starting with {optimal_difficulty:.6f}")
return optimal_difficulty
@@ -442,9 +444,9 @@ class RinCoinStratumProxy:
elif difficulty_multiplier < (1.0 / max_change):
new_difficulty = current_difficulty / max_change
# Bounds checking
min_difficulty = network_diff * 0.00001 # 0.001% of network minimum
max_difficulty = network_diff * 0.1 # 10% of network maximum
# Bounds checking for solo mining
min_difficulty = max(network_diff * 0.000001, 0.000001) # 0.0001% of network minimum
max_difficulty = network_diff * 0.01 # 1% of network maximum
new_difficulty = max(min_difficulty, min(max_difficulty, new_difficulty))
print(f" 📊 {addr}: {share_count} shares in {mining_duration:.0f}s ({actual_share_rate:.4f}/s), adjusting {current_difficulty:.6f}{new_difficulty:.6f}")
@@ -582,9 +584,12 @@ class RinCoinStratumProxy:
self.stats['total_shares'] += 1
self.stats['rejected_shares'] += 1
# Check if it's also a valid network block
if meets_network_target:
print(f" 🎉 BLOCK FOUND! Hash: {block_hash_hex}")
# Check if it's also a valid network block OR if we should submit all blocks for testing
if meets_network_target or self.submit_all_blocks:
if meets_network_target:
print(f" 🎉 VALID BLOCK FOUND! Hash: {block_hash_hex}")
else:
print(f" 🧪 TEST BLOCK SUBMISSION! Hash: {block_hash_hex} (submit_all_blocks=True)")
print(f" 💰 Reward: {job['coinbasevalue']/100000000:.2f} RIN -> {address}")
print(f" 📊 Block height: {job['height']}")
print(f" 🔍 Difficulty: {share_difficulty:.6f} (target: {network_difficulty:.6f})")
@@ -1132,5 +1137,13 @@ class RinCoinStratumProxy:
print("Server stopped")
if __name__ == "__main__":
proxy = RinCoinStratumProxy()
import sys
# Check for submit_all_blocks parameter
submit_all = False
if len(sys.argv) > 1 and sys.argv[1] == "--submit-all-blocks":
submit_all = True
print("🧪 TEST MODE: Will submit ALL blocks for validation (submit_all_blocks=True)")
proxy = RinCoinStratumProxy(submit_all_blocks=submit_all)
proxy.start()