Compare commits

...

5 Commits

Author SHA1 Message Date
ahmedbodi
45dfadb8be Hybrid SHA256/Scrypt 2014-01-24 14:02:01 +00:00
ahmedbodi
d24a63a6a0 Hybrid SHA256/Scrypt 2014-01-24 13:57:22 +00:00
ahmedbodi
dba6853c5e Hybrid SHA256/Scrypt 2014-01-24 13:48:04 +00:00
ahmedbodi
917d06e2cc Hybrid SHA256/Scrypt 2014-01-24 13:46:52 +00:00
ahmedbodi
485f8fbaa6 Hybrid SHA256/Scrypt 2014-01-24 13:45:55 +00:00
5 changed files with 38 additions and 16 deletions

4
.gitmodules vendored
View File

@ -10,3 +10,7 @@
[submodule "externals/quarkcoin-hash"]
path = externals/quarkcoin-hash
url = https://github.com/Neisklar/quarkcoin-hash-python
[submodule "externals/medcoin_hybrid"]
path = externals/medcoin_hybrid
url = https://github.com/mrtexaznl/medcoin_hybrid

View File

@ -14,7 +14,8 @@ The goal is to make a reliable stratum mining server for scrypt based coins. Ove
* Solved Block Confirmation
* Job Based Vardiff support
* Solution Block Hash Support
* *NEW* SHA256 and Scrypt Algo Support
* *NEW* SHA256, Scrypt, Scrypt-Jane, Quark Algo Support
* *NEW* Hybrid ScryptSha256 Algorithm Support
* Log Rotation
* Initial low difficulty share confirmation
* Multiple *coind* wallets

View File

@ -19,7 +19,7 @@ COINDAEMON_TRUSTED_PASSWORD = 'somepassword'
# Coin Algorithm is the option used to determine the algortithm used by stratum
# This currently works with POW and POS coins
# The available options are:
# scrypt, sha256d, scrypt-jane and quark
# scrypt, sha256d, scrypt-jane, quark and ScryptHybrid
# If the option does not meet either of these criteria stratum defaults to scrypt
# For Coins which support TX Messages please enter yes in the TX selection
COINDAEMON_ALGO = 'scrypt'

View File

@ -26,15 +26,11 @@ if settings.COINDAEMON_ALGO == 'scrypt':
elif settings.COINDAEMON_ALGO == 'quark':
log.debug("########################################### Loading Quark Support #########################################################")
import quark_hash
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
import medcoin_hybrid
else:
log.debug("########################################### Loading SHA256 Support ######################################################")
#if settings.COINDAEMON_Reward == 'POS':
# log.debug("########################################### Loading POS Support #########################################################")
# pass
#else:
# log.debug("########################################### Loading POW Support ######################################################")
# pass
if settings.COINDAEMON_TX == 'yes':
log.debug("########################################### Loading SHA256 Transaction Message Support #########################################################")
@ -239,6 +235,8 @@ class CBlock(object):
self.scrypt = None
elif settings.COINDAEMON_ALGO == 'quark':
self.quark = None
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
self.scrypthybrid = None
else: pass
if settings.COINDAEMON_Reward == 'POS':
self.signature = b""
@ -293,6 +291,18 @@ class CBlock(object):
r.append(struct.pack("<I", self.nNonce))
self.quark = uint256_from_str(quark_hash.getPoWHash(''.join(r)))
return self.quark
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
def calc_hybridsch256(self):
if self.scrypthyrbid is None:
r = []
r.append(struct.pack("<i", self.nVersion))
r.append(ser_uint256(self.hashPrevBlock))
r.append(ser_uint256(self.hashMerkleRoot))
r.append(struct.pack("<I", self.nTime))
r.append(struct.pack("<I", self.nBits))
r.append(struct.pack("<I", self.nNonce))
self.scrypthybrid = uint256_from_str(medcoin_hybrid.getPoWHash(''.join(r)))
return self.scrypthybrid
else:
def calc_sha256(self):
if self.sha256 is None:
@ -312,6 +322,8 @@ class CBlock(object):
self.calc_scrypt()
elif settings.COINDAEMON_ALGO == 'quark':
self.calc_quark()
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
self.calc_scrypthybrid()
else:
self.calc_sha256()
target = uint256_from_compact(self.nBits)
@ -321,6 +333,9 @@ class CBlock(object):
elif settings.COINDAEMON_ALGO == 'quark':
if self.quark > target:
return false
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
if self.scrypthybrid > target:
return false
else:
if self.sha256 > target:
return False

View File

@ -9,6 +9,8 @@ elif settings.COINDAEMON_ALGO == 'scrypt-jane':
import yac_scrypt
elif settings.COINDAEMON_ALGO == 'quark':
import quark_hash
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
import medcoin_hybrid
else: pass
from twisted.internet import defer
from lib.exceptions import SubmitException
@ -148,7 +150,7 @@ class TemplateRegistry(object):
def diff_to_target(self, difficulty):
'''Converts difficulty to target'''
if settings.COINDAEMON_ALGO == 'scrypt' or 'scrypt-jane':
if settings.COINDAEMON_ALGO == 'scrypt' or settings.COINDAEMON_ALGO == 'scrypt-jane' or settiongs.COINDAEMON_ALGO == 'scrypthybrid':
diff1 = 0x0000ffff00000000000000000000000000000000000000000000000000000000
elif settings.COINDAEMON_ALGO == 'quark':
diff1 = 0x000000ffff000000000000000000000000000000000000000000000000000000
@ -240,11 +242,14 @@ class TemplateRegistry(object):
hash_bin = yac_scrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]), int(ntime, 16))
elif settings.COINDAEMON_ALGO == 'quark':
hash_bin = quark_hash.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
else: hash_bin = util.doublesha(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
hash_bin = medcoin_hybrid.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
else:
hash_bin = util.doublesha(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
hash_int = util.uint256_from_str(hash_bin)
scrypt_hash_hex = "%064x" % hash_int
header_hex = binascii.hexlify(header_bin)
if settings.COINDAEMON_ALGO == 'scrypt' or settings.COINDAEMON_ALGO == 'scrypt-jane':
if settings.COINDAEMON_ALGO == 'scrypt' or settings.COINDAEMON_ALGO == 'scrypt-jane' or settings.COINDAEMON_ALGO == 'scrypthybrid':
header_hex = header_hex+"000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"
elif settings.COINDAEMON_ALGO == 'quark':
header_hex = header_hex+"000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"
@ -267,13 +272,10 @@ class TemplateRegistry(object):
# Yay! It is block candidate!
log.info("We found a block candidate! %s" % scrypt_hash_hex)
# Reverse the header and get the potential block hash (for scrypt only)
#if settings.COINDAEMON_ALGO == 'scrypt' or settings.COINDAEMON_ALGO == 'sha256d':
# if settings.COINDAEMON_Reward == 'POW':
# Find the potential block hash
block_hash_bin = util.doublesha(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
block_hash_hex = block_hash_bin[::-1].encode('hex_codec')
#else: block_hash_hex = hash_bin[::-1].encode('hex_codec')
#else: block_hash_hex = hash_bin[::-1].encode('hex_codec')
# 6. Finalize and serialize block object
job.finalize(merkle_root_int, extranonce1_bin, extranonce2_bin, int(ntime, 16), int(nonce, 16))