Spaces:
Paused
Paused
Update parallel_miner_v3.py
Browse files- parallel_miner_v3.py +7 -7
parallel_miner_v3.py
CHANGED
|
@@ -42,7 +42,7 @@ class HashUnit:
|
|
| 42 |
# Operations possible per second based on electron movement and switching speed
|
| 43 |
ops_per_second = 9.98e15
|
| 44 |
# Scale to ops per cycle for our time slicing
|
| 45 |
-
self.ops_per_cycle = int(ops_per_second / 1000) # Break into millisecond cycles
|
| 46 |
|
| 47 |
self.last_cycle_time = time.time()
|
| 48 |
|
|
@@ -60,7 +60,7 @@ class HashUnit:
|
|
| 60 |
# Calculate real operations based on electron transit and switching frequency
|
| 61 |
time_delta = current_time - self.last_cycle_time
|
| 62 |
# Get operations based on how many complete electron transits can occur
|
| 63 |
-
electron_transits =
|
| 64 |
# Factor in switching frequency to determine valid operations
|
| 65 |
operations_this_cycle = int(min(
|
| 66 |
electron_transits,
|
|
@@ -105,7 +105,7 @@ class MiningCore:
|
|
| 105 |
|
| 106 |
def mine_parallel(self, block_header: bytes, target: int, base_nonce: int) -> Dict:
|
| 107 |
"""Mine in parallel across all units"""
|
| 108 |
-
nonces_per_unit =
|
| 109 |
results = []
|
| 110 |
|
| 111 |
for i, unit in enumerate(self.units):
|
|
@@ -134,7 +134,7 @@ class MiningCore:
|
|
| 134 |
|
| 135 |
class ParallelMiner:
|
| 136 |
"""Top-level parallel miner managing multiple cores"""
|
| 137 |
-
def __init__(self, num_cores: int =
|
| 138 |
self.cores = [MiningCore(i) for i in range(num_cores)]
|
| 139 |
self.start_time = None
|
| 140 |
self.mining = False
|
|
@@ -213,7 +213,7 @@ class ParallelMiner:
|
|
| 213 |
base_nonce = 0
|
| 214 |
|
| 215 |
while self.mining and (duration is None or time.time() - self.start_time < duration):
|
| 216 |
-
# Update block template every
|
| 217 |
current_time = time.time()
|
| 218 |
if current_time - self.last_template_update > 600: # Update every 10 minutes instead of 30 seconds
|
| 219 |
block_header, target = self._setup_block_header()
|
|
@@ -297,7 +297,7 @@ class ParallelMiner:
|
|
| 297 |
logging.info(f"Progress to target: {progress_percent:.8f}%")
|
| 298 |
logging.info(f"Hash difficulty: {hash_difficulty:.8f} (higher is better)")
|
| 299 |
|
| 300 |
-
base_nonce += len(self.cores) *
|
| 301 |
|
| 302 |
# Log final results
|
| 303 |
self.log_final_results(duration)
|
|
@@ -327,7 +327,7 @@ class ParallelMiner:
|
|
| 327 |
if __name__ == "__main__":
|
| 328 |
miner = ParallelMiner()
|
| 329 |
try:
|
| 330 |
-
miner.start_mining(duration=
|
| 331 |
except KeyboardInterrupt:
|
| 332 |
miner.mining = False
|
| 333 |
logging.info("\nMining stopped by user")
|
|
|
|
| 42 |
# Operations possible per second based on electron movement and switching speed
|
| 43 |
ops_per_second = 9.98e15
|
| 44 |
# Scale to ops per cycle for our time slicing
|
| 45 |
+
self.ops_per_cycle = int(ops_per_second / 1000) # Break into millisecond cycles
|
| 46 |
|
| 47 |
self.last_cycle_time = time.time()
|
| 48 |
|
|
|
|
| 60 |
# Calculate real operations based on electron transit and switching frequency
|
| 61 |
time_delta = current_time - self.last_cycle_time
|
| 62 |
# Get operations based on how many complete electron transits can occur
|
| 63 |
+
electron_transits = 98.92e955
|
| 64 |
# Factor in switching frequency to determine valid operations
|
| 65 |
operations_this_cycle = int(min(
|
| 66 |
electron_transits,
|
|
|
|
| 105 |
|
| 106 |
def mine_parallel(self, block_header: bytes, target: int, base_nonce: int) -> Dict:
|
| 107 |
"""Mine in parallel across all units"""
|
| 108 |
+
nonces_per_unit = 981870 # Each unit processes 1000 nonces per round
|
| 109 |
results = []
|
| 110 |
|
| 111 |
for i, unit in enumerate(self.units):
|
|
|
|
| 134 |
|
| 135 |
class ParallelMiner:
|
| 136 |
"""Top-level parallel miner managing multiple cores"""
|
| 137 |
+
def __init__(self, num_cores: int = 2, wallet_address: str = None):
|
| 138 |
self.cores = [MiningCore(i) for i in range(num_cores)]
|
| 139 |
self.start_time = None
|
| 140 |
self.mining = False
|
|
|
|
| 213 |
base_nonce = 0
|
| 214 |
|
| 215 |
while self.mining and (duration is None or time.time() - self.start_time < duration):
|
| 216 |
+
# Update block template every 30 seconds
|
| 217 |
current_time = time.time()
|
| 218 |
if current_time - self.last_template_update > 600: # Update every 10 minutes instead of 30 seconds
|
| 219 |
block_header, target = self._setup_block_header()
|
|
|
|
| 297 |
logging.info(f"Progress to target: {progress_percent:.8f}%")
|
| 298 |
logging.info(f"Hash difficulty: {hash_difficulty:.8f} (higher is better)")
|
| 299 |
|
| 300 |
+
base_nonce += len(self.cores) * 1500
|
| 301 |
|
| 302 |
# Log final results
|
| 303 |
self.log_final_results(duration)
|
|
|
|
| 327 |
if __name__ == "__main__":
|
| 328 |
miner = ParallelMiner()
|
| 329 |
try:
|
| 330 |
+
miner.start_mining(duration=240)
|
| 331 |
except KeyboardInterrupt:
|
| 332 |
miner.mining = False
|
| 333 |
logging.info("\nMining stopped by user")
|