Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45dfadb8be | ||
|
|
d24a63a6a0 | ||
|
|
dba6853c5e | ||
|
|
917d06e2cc | ||
|
|
485f8fbaa6 |
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -10,3 +10,7 @@
|
|||||||
[submodule "externals/quarkcoin-hash"]
|
[submodule "externals/quarkcoin-hash"]
|
||||||
path = externals/quarkcoin-hash
|
path = externals/quarkcoin-hash
|
||||||
url = https://github.com/Neisklar/quarkcoin-hash-python
|
url = https://github.com/Neisklar/quarkcoin-hash-python
|
||||||
|
[submodule "externals/medcoin_hybrid"]
|
||||||
|
path = externals/medcoin_hybrid
|
||||||
|
url = https://github.com/mrtexaznl/medcoin_hybrid
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,8 @@ The goal is to make a reliable stratum mining server for scrypt based coins. Ove
|
|||||||
* Solved Block Confirmation
|
* Solved Block Confirmation
|
||||||
* Job Based Vardiff support
|
* Job Based Vardiff support
|
||||||
* Solution Block Hash 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
|
* Log Rotation
|
||||||
* Initial low difficulty share confirmation
|
* Initial low difficulty share confirmation
|
||||||
* Multiple *coind* wallets
|
* Multiple *coind* wallets
|
||||||
|
|||||||
@ -19,7 +19,7 @@ COINDAEMON_TRUSTED_PASSWORD = 'somepassword'
|
|||||||
# Coin Algorithm is the option used to determine the algortithm used by stratum
|
# Coin Algorithm is the option used to determine the algortithm used by stratum
|
||||||
# This currently works with POW and POS coins
|
# This currently works with POW and POS coins
|
||||||
# The available options are:
|
# 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
|
# 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
|
# For Coins which support TX Messages please enter yes in the TX selection
|
||||||
COINDAEMON_ALGO = 'scrypt'
|
COINDAEMON_ALGO = 'scrypt'
|
||||||
|
|||||||
@ -26,15 +26,11 @@ if settings.COINDAEMON_ALGO == 'scrypt':
|
|||||||
elif settings.COINDAEMON_ALGO == 'quark':
|
elif settings.COINDAEMON_ALGO == 'quark':
|
||||||
log.debug("########################################### Loading Quark Support #########################################################")
|
log.debug("########################################### Loading Quark Support #########################################################")
|
||||||
import quark_hash
|
import quark_hash
|
||||||
|
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
|
||||||
|
import medcoin_hybrid
|
||||||
else:
|
else:
|
||||||
log.debug("########################################### Loading SHA256 Support ######################################################")
|
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':
|
if settings.COINDAEMON_TX == 'yes':
|
||||||
log.debug("########################################### Loading SHA256 Transaction Message Support #########################################################")
|
log.debug("########################################### Loading SHA256 Transaction Message Support #########################################################")
|
||||||
@ -239,6 +235,8 @@ class CBlock(object):
|
|||||||
self.scrypt = None
|
self.scrypt = None
|
||||||
elif settings.COINDAEMON_ALGO == 'quark':
|
elif settings.COINDAEMON_ALGO == 'quark':
|
||||||
self.quark = None
|
self.quark = None
|
||||||
|
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
|
||||||
|
self.scrypthybrid = None
|
||||||
else: pass
|
else: pass
|
||||||
if settings.COINDAEMON_Reward == 'POS':
|
if settings.COINDAEMON_Reward == 'POS':
|
||||||
self.signature = b""
|
self.signature = b""
|
||||||
@ -293,6 +291,18 @@ class CBlock(object):
|
|||||||
r.append(struct.pack("<I", self.nNonce))
|
r.append(struct.pack("<I", self.nNonce))
|
||||||
self.quark = uint256_from_str(quark_hash.getPoWHash(''.join(r)))
|
self.quark = uint256_from_str(quark_hash.getPoWHash(''.join(r)))
|
||||||
return self.quark
|
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:
|
else:
|
||||||
def calc_sha256(self):
|
def calc_sha256(self):
|
||||||
if self.sha256 is None:
|
if self.sha256 is None:
|
||||||
@ -312,6 +322,8 @@ class CBlock(object):
|
|||||||
self.calc_scrypt()
|
self.calc_scrypt()
|
||||||
elif settings.COINDAEMON_ALGO == 'quark':
|
elif settings.COINDAEMON_ALGO == 'quark':
|
||||||
self.calc_quark()
|
self.calc_quark()
|
||||||
|
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
|
||||||
|
self.calc_scrypthybrid()
|
||||||
else:
|
else:
|
||||||
self.calc_sha256()
|
self.calc_sha256()
|
||||||
target = uint256_from_compact(self.nBits)
|
target = uint256_from_compact(self.nBits)
|
||||||
@ -321,6 +333,9 @@ class CBlock(object):
|
|||||||
elif settings.COINDAEMON_ALGO == 'quark':
|
elif settings.COINDAEMON_ALGO == 'quark':
|
||||||
if self.quark > target:
|
if self.quark > target:
|
||||||
return false
|
return false
|
||||||
|
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
|
||||||
|
if self.scrypthybrid > target:
|
||||||
|
return false
|
||||||
else:
|
else:
|
||||||
if self.sha256 > target:
|
if self.sha256 > target:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@ -9,6 +9,8 @@ elif settings.COINDAEMON_ALGO == 'scrypt-jane':
|
|||||||
import yac_scrypt
|
import yac_scrypt
|
||||||
elif settings.COINDAEMON_ALGO == 'quark':
|
elif settings.COINDAEMON_ALGO == 'quark':
|
||||||
import quark_hash
|
import quark_hash
|
||||||
|
elif settings.COINDAEMON_ALGO == 'scrypthybrid':
|
||||||
|
import medcoin_hybrid
|
||||||
else: pass
|
else: pass
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from lib.exceptions import SubmitException
|
from lib.exceptions import SubmitException
|
||||||
@ -148,7 +150,7 @@ class TemplateRegistry(object):
|
|||||||
|
|
||||||
def diff_to_target(self, difficulty):
|
def diff_to_target(self, difficulty):
|
||||||
'''Converts difficulty to target'''
|
'''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
|
diff1 = 0x0000ffff00000000000000000000000000000000000000000000000000000000
|
||||||
elif settings.COINDAEMON_ALGO == 'quark':
|
elif settings.COINDAEMON_ALGO == 'quark':
|
||||||
diff1 = 0x000000ffff000000000000000000000000000000000000000000000000000000
|
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))
|
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':
|
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) ]))
|
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)
|
hash_int = util.uint256_from_str(hash_bin)
|
||||||
scrypt_hash_hex = "%064x" % hash_int
|
scrypt_hash_hex = "%064x" % hash_int
|
||||||
header_hex = binascii.hexlify(header_bin)
|
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"
|
header_hex = header_hex+"000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"
|
||||||
elif settings.COINDAEMON_ALGO == 'quark':
|
elif settings.COINDAEMON_ALGO == 'quark':
|
||||||
header_hex = header_hex+"000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"
|
header_hex = header_hex+"000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"
|
||||||
@ -267,13 +272,10 @@ class TemplateRegistry(object):
|
|||||||
# Yay! It is block candidate!
|
# Yay! It is block candidate!
|
||||||
log.info("We found a block candidate! %s" % scrypt_hash_hex)
|
log.info("We found a block candidate! %s" % scrypt_hash_hex)
|
||||||
|
|
||||||
# Reverse the header and get the potential block hash (for scrypt only)
|
# Find the potential block hash
|
||||||
#if settings.COINDAEMON_ALGO == 'scrypt' or settings.COINDAEMON_ALGO == 'sha256d':
|
|
||||||
# if settings.COINDAEMON_Reward == 'POW':
|
|
||||||
block_hash_bin = util.doublesha(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
|
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')
|
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
|
# 6. Finalize and serialize block object
|
||||||
job.finalize(merkle_root_int, extranonce1_bin, extranonce2_bin, int(ntime, 16), int(nonce, 16))
|
job.finalize(merkle_root_int, extranonce1_bin, extranonce2_bin, int(ntime, 16), int(nonce, 16))
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user