Skip to content

Commit d44f0ab

Browse files
Stabilty
1 parent fc19613 commit d44f0ab

File tree

2 files changed

+28
-82
lines changed

2 files changed

+28
-82
lines changed

cluster_worker.py

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -56,38 +56,24 @@ def ducos1(
5656
expectedHash,
5757
start,
5858
end):
59-
'''
60-
Blatently stole it from:
61-
https://github.com/colonelwatch/nonceMiner/blob/master/src/mine_DUCO_S1.c
62-
'''
6359
global END_JOB,calculation_result
6460
hashcount = 0
65-
6661
base_hash = hashlib.sha1(str(lastBlockHash).encode('ascii'))
6762
temp_hash = None
68-
cache = []
69-
70-
for ducos1xxres in range(start,end):
63+
for ducos1xxres in range(int(start),int(end)):
7164
if END_JOB:
7265
logger.info('JOB TERMINATED')
7366
calculation_result = [None,0,0,0,None]
7467
return None
75-
if ducos1xxres<10:
76-
temp_hash = base_hash.copy()
77-
temp_hash.update(str(ducos1xxres).encode('ascii'))
78-
elif ducos1xxres<end//10:
79-
temp_hash = cache[int(ducos1xxres//10)].copy()
80-
temp_hash.update(str(ducos1xxres%10).encode('ascii'))
81-
else:
82-
temp_hash = cache[ducos1xxres//100].copy()
83-
temp_hash.update(str(ducos1xxres%100).encode('ascii'))
84-
if(ducos1xxres<end//100):
85-
cache.append(temp_hash)
86-
ducos1xx = temp_hash.hexdigest()
68+
temp_hash = base_hash.copy()
69+
temp_hash.update(str(ducos1xxres).encode('ascii'))
70+
ducos1xx = temp_hash.hexdigest()
71+
# Increment hash counter for hashrate calculator
8772
hashcount += 1
73+
# Check if result was found
8874
if ducos1xx == expectedHash:
8975
END_JOB = True
90-
logger.debug(str(ducos1xxres))
76+
logger.debug('LEFT '+str(ducos1xxres))
9177
calculation_result = [ducos1xxres, hashcount,start,end,expectedHash]
9278
return None
9379
logger.info('Empty block')
@@ -101,29 +87,20 @@ def ducos1xxh(
10187
end):
10288
global END_JOB,calculation_result
10389
hashcount = 0
104-
105-
base_hash = xxhash.xxh64(str(lastBlockHash).encode('ascii'))
90+
base_hash = xxhash.xxh64(str(lastBlockHash),seed=2811)
10691
temp_hash = None
107-
cache = []
108-
109-
for ducos1xxres in range(start,end):
92+
for ducos1xxres in range(int(start),int(end)):
11093
if END_JOB:
11194
logger.info('JOB TERMINATED')
11295
calculation_result = [None,0,0,0,None]
11396
return None
114-
if ducos1xxres<10:
115-
temp_hash = base_hash.copy()
116-
temp_hash.update(str(ducos1xxres).encode('ascii'))
117-
elif ducos1xxres<end//10:
118-
temp_hash = cache[int(ducos1xxres//10)].copy()
119-
temp_hash.update(str(ducos1xxres%10).encode('ascii'))
120-
else:
121-
temp_hash = cache[ducos1xxres//100].copy()
122-
temp_hash.update(str(ducos1xxres%100).encode('ascii'))
123-
if(ducos1xxres<end//100):
124-
cache.append(temp_hash)
125-
ducos1xx = temp_hash.hexdigest()
97+
98+
temp_hash = base_hash.copy()
99+
temp_hash.update(str(ducos1xxres))
100+
ducos1xx = temp_hash.hexdigest()
101+
# Increment hash counter for hashrate calculator
126102
hashcount += 1
103+
# Check if result was found
127104
if ducos1xx == expectedHash:
128105
END_JOB = True
129106
logger.debug('LEFT '+str(ducos1xxres))
@@ -452,4 +429,4 @@ def client():
452429
#tr = traceback.format_exc()
453430
logger.warning('ERROR ACCURED',exc_info=e)
454431

455-
input()
432+
input()

cluster_worker_multiprocessing.py

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -44,41 +44,24 @@ def ducos1(
4444
expectedHash,
4545
start,
4646
end):
47-
'''
48-
Blatently stole it from:
49-
https://github.com/colonelwatch/nonceMiner/blob/master/src/mine_DUCO_S1.c
50-
'''
5147
global END_JOB,calculation_result
5248
hashcount = 0
53-
5449
base_hash = hashlib.sha1(str(lastBlockHash).encode('ascii'))
5550
temp_hash = None
56-
cache = []
57-
58-
for ducos1xxres in range(start,end):
51+
for ducos1xxres in range(int(start),int(end)):
5952
if END_JOB:
60-
logger.info('JOB TERMINATED')
6153
calculation_result = [None,0,0,0,None]
6254
return None
63-
if ducos1xxres<10:
64-
temp_hash = base_hash.copy()
65-
temp_hash.update(str(ducos1xxres).encode('ascii'))
66-
elif ducos1xxres<end//10:
67-
temp_hash = cache[int(ducos1xxres//10)].copy()
68-
temp_hash.update(str(ducos1xxres%10).encode('ascii'))
69-
else:
70-
temp_hash = cache[ducos1xxres//100].copy()
71-
temp_hash.update(str(ducos1xxres%100).encode('ascii'))
72-
if(ducos1xxres<end//100):
73-
cache.append(temp_hash)
74-
ducos1xx = temp_hash.hexdigest()
55+
temp_hash = base_hash.copy()
56+
temp_hash.update(str(ducos1xxres).encode('ascii'))
57+
ducos1xx = temp_hash.hexdigest()
58+
# Increment hash counter for hashrate calculator
7559
hashcount += 1
60+
# Check if result was found
7661
if ducos1xx == expectedHash:
7762
END_JOB = True
78-
logger.debug(str(ducos1xxres))
7963
calculation_result = [ducos1xxres, hashcount,start,end,expectedHash]
8064
return None
81-
logger.info('Empty block')
8265
END_JOB = True
8366
calculation_result = [None,hashcount,start,end,expectedHash]
8467

@@ -89,35 +72,21 @@ def ducos1xxh(
8972
end):
9073
global END_JOB,calculation_result
9174
hashcount = 0
92-
93-
base_hash = xxhash.xxh64(str(lastBlockHash).encode('ascii'))
75+
base_hash = xxhash.xxh64(str(lastBlockHash),seed=2811)
9476
temp_hash = None
95-
cache = []
96-
97-
for ducos1xxres in range(start,end):
77+
for ducos1xxres in range(int(start),int(end)):
9878
if END_JOB:
99-
logger.info('JOB TERMINATED')
10079
calculation_result = [None,0,0,0,None]
10180
return None
102-
if ducos1xxres<10:
103-
temp_hash = base_hash.copy()
104-
temp_hash.update(str(ducos1xxres).encode('ascii'))
105-
elif ducos1xxres<end//10:
106-
temp_hash = cache[int(ducos1xxres//10)].copy()
107-
temp_hash.update(str(ducos1xxres%10).encode('ascii'))
108-
else:
109-
temp_hash = cache[ducos1xxres//100].copy()
110-
temp_hash.update(str(ducos1xxres%100).encode('ascii'))
111-
if(ducos1xxres<end//100):
112-
cache.append(temp_hash)
113-
ducos1xx = temp_hash.hexdigest()
81+
82+
temp_hash = base_hash.copy()
83+
temp_hash.update(str(ducos1xxres))
84+
ducos1xx = temp_hash.hexdigest()
11485
hashcount += 1
11586
if ducos1xx == expectedHash:
11687
END_JOB = True
117-
logger.debug('LEFT '+str(ducos1xxres))
11888
calculation_result = [ducos1xxres, hashcount,start,end,expectedHash]
11989
return None
120-
logger.info('Empty block')
12190
END_JOB = True
12291
calculation_result = [None,hashcount,start,end,expectedHash]
12392

0 commit comments

Comments
 (0)