Skip to content

Commit 87c5bb9

Browse files
authored
Update context.py
1 parent e082263 commit 87c5bb9

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

context.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
# context.py for CPU-based Bitcoin Mining
2+
3+
# Flag to indicate if the mining process should be shut down
14
fShutdown = False
5+
6+
# List to keep track of the running state of threads (e.g., mining, listening)
27
listfThreadRunning = [False] * 2
8+
9+
# Current height of the local blockchain copy
310
local_height = 0
11+
12+
# Dictionary to store the best difficulty achieved for each height
413
nHeightDiff = {}
14+
15+
# Hash of the previous block (to detect new blocks in the network)
516
updatedPrevHash = None
17+
18+
# Mining-related parameters (updated with each new block or job)
619
job_id = None
720
prevhash = None
821
coinb1 = None
@@ -15,3 +28,33 @@
1528
sub_details = None
1629
extranonce1 = None
1730
extranonce2_size = None
31+
32+
# Performance Metrics for CPU Mining
33+
total_hashes_computed = 0 # Total number of hashes computed
34+
hash_rate = 0 # Hash rate (hashes per second)
35+
mining_time_per_block = [] # Time taken to mine each block
36+
resource_utilization = { # Resource utilization (CPU, memory)
37+
'cpu_usage': 0,
38+
'memory_usage': 0
39+
}
40+
41+
# Network Statistics
42+
network_difficulty = None # Current network difficulty
43+
average_block_time = None # Average time for block discovery in the network
44+
45+
# Error Handling and Logging
46+
error_count = 0 # Number of errors encountered
47+
last_error_message = "" # Last error message for debugging
48+
49+
# Adaptive Mining Configuration
50+
adaptive_difficulty = True # Flag to enable adaptive difficulty
51+
reconnection_attempts = 0 # Number of attempts to reconnect to the pool
52+
53+
# Blockchain Data
54+
last_block_hashes = [] # Store hashes of the last N blocks
55+
56+
# User Customization
57+
user_preferences = {
58+
'logging_level': 'info',
59+
'ui_settings': {}
60+
}

0 commit comments

Comments
 (0)