Skip to content

Commit

Permalink
Stabilty
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorEenot committed Apr 14, 2021
1 parent fc19613 commit d44f0ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 82 deletions.
55 changes: 16 additions & 39 deletions cluster_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,24 @@ def ducos1(
expectedHash,
start,
end):
'''
Blatently stole it from:
https://github.com/colonelwatch/nonceMiner/blob/master/src/mine_DUCO_S1.c
'''
global END_JOB,calculation_result
hashcount = 0

base_hash = hashlib.sha1(str(lastBlockHash).encode('ascii'))
temp_hash = None
cache = []

for ducos1xxres in range(start,end):
for ducos1xxres in range(int(start),int(end)):
if END_JOB:
logger.info('JOB TERMINATED')
calculation_result = [None,0,0,0,None]
return None
if ducos1xxres<10:
temp_hash = base_hash.copy()
temp_hash.update(str(ducos1xxres).encode('ascii'))
elif ducos1xxres<end//10:
temp_hash = cache[int(ducos1xxres//10)].copy()
temp_hash.update(str(ducos1xxres%10).encode('ascii'))
else:
temp_hash = cache[ducos1xxres//100].copy()
temp_hash.update(str(ducos1xxres%100).encode('ascii'))
if(ducos1xxres<end//100):
cache.append(temp_hash)
ducos1xx = temp_hash.hexdigest()
temp_hash = base_hash.copy()
temp_hash.update(str(ducos1xxres).encode('ascii'))
ducos1xx = temp_hash.hexdigest()
# Increment hash counter for hashrate calculator
hashcount += 1
# Check if result was found
if ducos1xx == expectedHash:
END_JOB = True
logger.debug(str(ducos1xxres))
logger.debug('LEFT '+str(ducos1xxres))
calculation_result = [ducos1xxres, hashcount,start,end,expectedHash]
return None
logger.info('Empty block')
Expand All @@ -101,29 +87,20 @@ def ducos1xxh(
end):
global END_JOB,calculation_result
hashcount = 0

base_hash = xxhash.xxh64(str(lastBlockHash).encode('ascii'))
base_hash = xxhash.xxh64(str(lastBlockHash),seed=2811)
temp_hash = None
cache = []

for ducos1xxres in range(start,end):
for ducos1xxres in range(int(start),int(end)):
if END_JOB:
logger.info('JOB TERMINATED')
calculation_result = [None,0,0,0,None]
return None
if ducos1xxres<10:
temp_hash = base_hash.copy()
temp_hash.update(str(ducos1xxres).encode('ascii'))
elif ducos1xxres<end//10:
temp_hash = cache[int(ducos1xxres//10)].copy()
temp_hash.update(str(ducos1xxres%10).encode('ascii'))
else:
temp_hash = cache[ducos1xxres//100].copy()
temp_hash.update(str(ducos1xxres%100).encode('ascii'))
if(ducos1xxres<end//100):
cache.append(temp_hash)
ducos1xx = temp_hash.hexdigest()

temp_hash = base_hash.copy()
temp_hash.update(str(ducos1xxres))
ducos1xx = temp_hash.hexdigest()
# Increment hash counter for hashrate calculator
hashcount += 1
# Check if result was found
if ducos1xx == expectedHash:
END_JOB = True
logger.debug('LEFT '+str(ducos1xxres))
Expand Down Expand Up @@ -452,4 +429,4 @@ def client():
#tr = traceback.format_exc()
logger.warning('ERROR ACCURED',exc_info=e)

input()
input()
55 changes: 12 additions & 43 deletions cluster_worker_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,24 @@ def ducos1(
expectedHash,
start,
end):
'''
Blatently stole it from:
https://github.com/colonelwatch/nonceMiner/blob/master/src/mine_DUCO_S1.c
'''
global END_JOB,calculation_result
hashcount = 0

base_hash = hashlib.sha1(str(lastBlockHash).encode('ascii'))
temp_hash = None
cache = []

for ducos1xxres in range(start,end):
for ducos1xxres in range(int(start),int(end)):
if END_JOB:
logger.info('JOB TERMINATED')
calculation_result = [None,0,0,0,None]
return None
if ducos1xxres<10:
temp_hash = base_hash.copy()
temp_hash.update(str(ducos1xxres).encode('ascii'))
elif ducos1xxres<end//10:
temp_hash = cache[int(ducos1xxres//10)].copy()
temp_hash.update(str(ducos1xxres%10).encode('ascii'))
else:
temp_hash = cache[ducos1xxres//100].copy()
temp_hash.update(str(ducos1xxres%100).encode('ascii'))
if(ducos1xxres<end//100):
cache.append(temp_hash)
ducos1xx = temp_hash.hexdigest()
temp_hash = base_hash.copy()
temp_hash.update(str(ducos1xxres).encode('ascii'))
ducos1xx = temp_hash.hexdigest()
# Increment hash counter for hashrate calculator
hashcount += 1
# Check if result was found
if ducos1xx == expectedHash:
END_JOB = True
logger.debug(str(ducos1xxres))
calculation_result = [ducos1xxres, hashcount,start,end,expectedHash]
return None
logger.info('Empty block')
END_JOB = True
calculation_result = [None,hashcount,start,end,expectedHash]

Expand All @@ -89,35 +72,21 @@ def ducos1xxh(
end):
global END_JOB,calculation_result
hashcount = 0

base_hash = xxhash.xxh64(str(lastBlockHash).encode('ascii'))
base_hash = xxhash.xxh64(str(lastBlockHash),seed=2811)
temp_hash = None
cache = []

for ducos1xxres in range(start,end):
for ducos1xxres in range(int(start),int(end)):
if END_JOB:
logger.info('JOB TERMINATED')
calculation_result = [None,0,0,0,None]
return None
if ducos1xxres<10:
temp_hash = base_hash.copy()
temp_hash.update(str(ducos1xxres).encode('ascii'))
elif ducos1xxres<end//10:
temp_hash = cache[int(ducos1xxres//10)].copy()
temp_hash.update(str(ducos1xxres%10).encode('ascii'))
else:
temp_hash = cache[ducos1xxres//100].copy()
temp_hash.update(str(ducos1xxres%100).encode('ascii'))
if(ducos1xxres<end//100):
cache.append(temp_hash)
ducos1xx = temp_hash.hexdigest()

temp_hash = base_hash.copy()
temp_hash.update(str(ducos1xxres))
ducos1xx = temp_hash.hexdigest()
hashcount += 1
if ducos1xx == expectedHash:
END_JOB = True
logger.debug('LEFT '+str(ducos1xxres))
calculation_result = [ducos1xxres, hashcount,start,end,expectedHash]
return None
logger.info('Empty block')
END_JOB = True
calculation_result = [None,hashcount,start,end,expectedHash]

Expand Down

0 comments on commit d44f0ab

Please sign in to comment.