Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12fa1a4e97 | ||
|
|
1ec817b248 | ||
|
|
4a68da7bcd | ||
|
|
5f8a1ff51d | ||
|
|
7e4f9cd58f | ||
|
|
67f74ff9ef | ||
|
|
56cd8940b1 | ||
|
|
5e5d6b9b14 | ||
|
|
73385d3f79 | ||
|
|
0d1e796517 | ||
|
|
96e4fa20e4 | ||
|
|
dfe2da32b5 | ||
|
|
396f966d70 | ||
|
|
c8142e3297 | ||
|
|
909aec6cb6 | ||
|
|
12b6b696ef | ||
|
|
e8521991af | ||
|
|
bf3c4b84bc | ||
|
|
dfc3b800d1 | ||
|
|
bb78d0e128 | ||
|
|
9191786fe5 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -10,3 +10,6 @@
|
||||
[submodule "externals/quarkcoin-hash"]
|
||||
path = externals/quarkcoin-hash
|
||||
url = https://github.com/Neisklar/quarkcoin-hash-python
|
||||
[submodule "externals/vertcoin_scrypt"]
|
||||
path = externals/vertcoin_scrypt
|
||||
url = https://github.com/scr34m/vertcoin_scrypt.git
|
||||
|
||||
@ -5,7 +5,8 @@ Please rename it to config.py and fill correct values.
|
||||
This is already setup with sane values for solomining.
|
||||
You NEED to set the parameters in BASIC SETTINGS
|
||||
'''
|
||||
|
||||
#********************* Config Version ***************
|
||||
CONFIG_VERSION = 0.1
|
||||
# ******************** BASIC SETTINGS ***************
|
||||
# These are the MUST BE SET parameters!
|
||||
|
||||
@ -16,14 +17,10 @@ COINDAEMON_TRUSTED_PORT = 8332
|
||||
COINDAEMON_TRUSTED_USER = 'user'
|
||||
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, skeinhash, and quark
|
||||
# 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'
|
||||
COINDAEMON_TX = 'no'
|
||||
COINDAEMON_ALGO = 'scrypt' # The available options are: scrypt, sha256d, scrypt-jane, skeinhash, and quark
|
||||
SCRYPTJANE_NAME = 'vtc_scrypt'# Set this to the Scrypt jane module name e.g. yac_scrypt or vtc_scrypt
|
||||
COINDAEMON_TX = False # For Coins which support TX Messages please enter yes in the TX selection
|
||||
|
||||
# ******************** BASIC SETTINGS ***************
|
||||
# Backup Coin Daemon address's (consider having at least 1 backup)
|
||||
# You can have up to 99
|
||||
@ -139,7 +136,7 @@ MERKLE_REFRESH_INTERVAL = 60 # How often check memorypool
|
||||
INSTANCE_ID = 31 # Used for extranonce and needs to be 0-31
|
||||
|
||||
# ******************** Pool Difficulty Settings *********************
|
||||
VDIFF_X2_TYPE = True # powers of 2 e.g. 2,4,8,16,32,64,128,256,512,1024
|
||||
VDIFF_X2_TYPE = False # powers of 2 e.g. 2,4,8,16,32,64,128,256,512,1024
|
||||
VDIFF_FLOAT = False # Use float difficulty
|
||||
|
||||
# Pool Target (Base Difficulty)
|
||||
|
||||
1
externals/vertcoin_scrypt
vendored
Submodule
1
externals/vertcoin_scrypt
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 4a3d789cf4fd713308f26610e39e81cb7d86423f
|
||||
@ -39,7 +39,7 @@ class CoinbaseTransactionPOW(halfnode.CTransaction):
|
||||
tx_out.nValue = value
|
||||
tx_out.scriptPubKey = coinbaser.get_script_pubkey()
|
||||
|
||||
if settings.COINDAEMON_TX == 'yes':
|
||||
if settings.COINDAEMON_TX != False:
|
||||
self.strTxComment = "http://github.com/ahmedbodi/stratum-mining"
|
||||
self.vin.append(tx_in)
|
||||
self.vout.append(tx_out)
|
||||
@ -87,7 +87,7 @@ class CoinbaseTransactionPOS(halfnode.CTransaction):
|
||||
tx_out.scriptPubKey = coinbaser.get_script_pubkey()
|
||||
|
||||
self.nTime = ntime
|
||||
if settings.COINDAEMON_SHA256_TX == 'yes':
|
||||
if settings.COINDAEMON_SHA256_TX != False:
|
||||
self.strTxComment = "http://github.com/ahmedbodi/stratum-mining"
|
||||
self.vin.append(tx_in)
|
||||
self.vout.append(tx_out)
|
||||
|
||||
@ -23,20 +23,18 @@ log.debug("Got to Halfnode")
|
||||
if settings.COINDAEMON_ALGO == 'scrypt':
|
||||
log.debug("########################################### Loading LTC Scrypt #########################################################")
|
||||
import ltc_scrypt
|
||||
elif settings.COINDAEMON_ALGO == 'scrypt-jane':
|
||||
__import__(settings.SCRYPTJANE_NAME)
|
||||
log.debug("########################################### LoadingScrypt jane #########################################################")
|
||||
elif settings.COINDAEMON_ALGO == 'quark':
|
||||
log.debug("########################################### Loading Quark Support #########################################################")
|
||||
import quark_hash
|
||||
elif settings.COINDAEMON_ALGO == 'skeinhash':
|
||||
import skeinhash
|
||||
|
||||
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':
|
||||
if settings.COINDAEMON_TX != False:
|
||||
log.debug("########################################### Loading SHA256 Transaction Message Support #########################################################")
|
||||
pass
|
||||
else:
|
||||
@ -158,7 +156,7 @@ class CTransaction(object):
|
||||
def __init__(self):
|
||||
if settings.COINDAEMON_Reward == 'POW':
|
||||
self.nVersion = 1
|
||||
if settings.COINDAEMON_TX == 'yes':
|
||||
if settings.COINDAEMON_TX != False:
|
||||
self.nVersion = 2
|
||||
self.vin = []
|
||||
self.vout = []
|
||||
@ -166,14 +164,14 @@ class CTransaction(object):
|
||||
self.sha256 = None
|
||||
elif settings.COINDAEMON_Reward == 'POS':
|
||||
self.nVersion = 1
|
||||
if settings.COINDAEMON_TX == 'yes':
|
||||
if settings.COINDAEMON_TX != False:
|
||||
self.nVersion = 2
|
||||
self.nTime = 0
|
||||
self.vin = []
|
||||
self.vout = []
|
||||
self.nLockTime = 0
|
||||
self.sha256 = None
|
||||
if settings.COINDAEMON_TX == 'yes':
|
||||
if settings.COINDAEMON_TX != False:
|
||||
self.strTxComment = ""
|
||||
|
||||
def deserialize(self, f):
|
||||
@ -190,7 +188,7 @@ class CTransaction(object):
|
||||
self.vout = deser_vector(f, CTxOut)
|
||||
self.nLockTime = struct.unpack("<I", f.read(4))[0]
|
||||
self.sha256 = None
|
||||
if settings.COINDAEMON_TX == 'yes':
|
||||
if settings.COINDAEMON_TX != False:
|
||||
self.strTxComment = deser_string(f)
|
||||
|
||||
def serialize(self):
|
||||
@ -207,7 +205,7 @@ class CTransaction(object):
|
||||
r += ser_vector(self.vin)
|
||||
r += ser_vector(self.vout)
|
||||
r += struct.pack("<I", self.nLockTime)
|
||||
if settings.COINDAEMON_TX == 'yes':
|
||||
if settings.COINDAEMON_TX != False:
|
||||
r += ser_string(self.strTxComment)
|
||||
return r
|
||||
|
||||
@ -236,10 +234,13 @@ class CBlock(object):
|
||||
self.vtx = []
|
||||
self.sha256 = None
|
||||
if settings.COINDAEMON_ALGO == 'scrypt':
|
||||
self.scrypt = None
|
||||
self.scrypt= None
|
||||
elif settings.COINDAEMON_ALGO == 'scrypt-jane':
|
||||
self.scryptjane = None
|
||||
elif settings.COINDAEMON_ALGO == 'quark':
|
||||
self.quark = None
|
||||
else: pass
|
||||
elif settings.COINDAEMON_ALGO == 'skein':
|
||||
self.skein = None
|
||||
if settings.COINDAEMON_Reward == 'POS':
|
||||
self.signature = b""
|
||||
else: pass
|
||||
@ -294,6 +295,30 @@ 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 == 'scrypt-jane':
|
||||
def calc_scryptjane(self):
|
||||
if self.scryptjane 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.scryptjane = uint256_from_str(settings.SCRYPTJANE_NAME.getPoWHash(''.join(r)))
|
||||
return self.scryptjane
|
||||
elif settings.COINDAEMON_ALGO == 'skein':
|
||||
def calc_skein(self):
|
||||
if self.skein 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.skein = uint256_from_str(skeinhash.skeinhash(''.join(r)))
|
||||
return self.skein
|
||||
else:
|
||||
def calc_sha256(self):
|
||||
if self.sha256 is None:
|
||||
@ -313,6 +338,10 @@ class CBlock(object):
|
||||
self.calc_scrypt()
|
||||
elif settings.COINDAEMON_ALGO == 'quark':
|
||||
self.calc_quark()
|
||||
elif settings.COINDAEMON_ALGO == 'scrypt-jane':
|
||||
self.calc_scryptjane
|
||||
elif settings.COINDAEMON_ALGO == 'skein':
|
||||
self.calc_skein
|
||||
else:
|
||||
self.calc_sha256()
|
||||
|
||||
@ -324,6 +353,12 @@ class CBlock(object):
|
||||
elif settings.COINDAEMON_ALGO == 'quark':
|
||||
if self.quark > target:
|
||||
return False
|
||||
elif settings.COINDAEMON_ALGO == 'scrypt-jane':
|
||||
if self.scryptjane > target:
|
||||
return False
|
||||
elif settings.COINDAEMON_ALGO == 'skein':
|
||||
if self.skein > target:
|
||||
return False
|
||||
else:
|
||||
if self.sha256 > target:
|
||||
return False
|
||||
|
||||
@ -6,7 +6,7 @@ import settings
|
||||
if settings.COINDAEMON_ALGO == 'scrypt':
|
||||
import ltc_scrypt
|
||||
elif settings.COINDAEMON_ALGO == 'scrypt-jane':
|
||||
import yac_scrypt
|
||||
scryptjane = __import__(settings.SCRYPTJANE_NAME)
|
||||
elif settings.COINDAEMON_ALGO == 'quark':
|
||||
import quark_hash
|
||||
elif settings.COINDAEMON_ALGO == 'skeinhash':
|
||||
@ -159,12 +159,16 @@ class TemplateRegistry(object):
|
||||
|
||||
return diff1 / difficulty
|
||||
|
||||
def get_job(self, job_id):
|
||||
def get_job(self, job_id, worker_name, ip=False):
|
||||
'''For given job_id returns BlockTemplate instance or None'''
|
||||
try:
|
||||
j = self.jobs[job_id]
|
||||
except:
|
||||
log.info("Job id '%s' not found" % job_id)
|
||||
log.info("Job id '%s' not found, worker_name: '%s'" % (job_id, worker_name))
|
||||
|
||||
if ip:
|
||||
log.info("Worker submited invalid Job id: IP %s", str(ip))
|
||||
|
||||
return None
|
||||
|
||||
# Now we have to check if job is still valid.
|
||||
@ -181,7 +185,7 @@ class TemplateRegistry(object):
|
||||
return j
|
||||
|
||||
def submit_share(self, job_id, worker_name, session, extranonce1_bin, extranonce2, ntime, nonce,
|
||||
difficulty):
|
||||
difficulty, ip=False):
|
||||
'''Check parameters and finalize block template. If it leads
|
||||
to valid block candidate, asynchronously submits the block
|
||||
back to the bitcoin network.
|
||||
@ -197,7 +201,7 @@ class TemplateRegistry(object):
|
||||
raise SubmitException("Incorrect size of extranonce2. Expected %d chars" % (self.extranonce2_size*2))
|
||||
|
||||
# Check for job
|
||||
job = self.get_job(job_id)
|
||||
job = self.get_job(job_id, worker_name, ip)
|
||||
if job == None:
|
||||
raise SubmitException("Job '%s' not found" % job_id)
|
||||
|
||||
@ -241,7 +245,10 @@ class TemplateRegistry(object):
|
||||
if settings.COINDAEMON_ALGO == 'scrypt':
|
||||
hash_bin = ltc_scrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
|
||||
elif settings.COINDAEMON_ALGO == 'scrypt-jane':
|
||||
hash_bin = yac_scrypt.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]), int(ntime, 16))
|
||||
if settings.SCRYPTJANE_NAME == 'vtc_scrypt':
|
||||
hash_bin = scryptjane.getPoWHash(''.join([ header_bin[i*4:i*4+4][::-1] for i in range(0, 20) ]))
|
||||
else:
|
||||
hash_bin = scryptjane.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) ]))
|
||||
elif settings.COINDAEMON_ALGO == 'skeinhash':
|
||||
|
||||
@ -7,7 +7,6 @@ import simplejson as json
|
||||
from twisted.internet import reactor
|
||||
import threading
|
||||
from mining.work_log_pruner import WorkLogPruner
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def setup(on_startup):
|
||||
'''Setup mining service internal environment.
|
||||
@ -17,11 +16,13 @@ def setup(on_startup):
|
||||
*before* you call setup() in the launcher script.'''
|
||||
|
||||
import lib.settings as settings
|
||||
|
||||
|
||||
# Get logging online as soon as possible
|
||||
import lib.logger
|
||||
log = lib.logger.get_logger('mining')
|
||||
|
||||
if settings.CONFIG_VERSION == None:
|
||||
settings.CONFIG_VERSION = 0
|
||||
else: pass
|
||||
from interfaces import Interfaces
|
||||
|
||||
from lib.block_updater import BlockUpdater
|
||||
@ -31,7 +32,6 @@ def setup(on_startup):
|
||||
from lib.coinbaser import SimpleCoinbaser
|
||||
|
||||
bitcoin_rpc = BitcoinRPCManager()
|
||||
|
||||
# Check litecoind
|
||||
# Check we can connect (sleep)
|
||||
# Check the results:
|
||||
@ -41,7 +41,7 @@ def setup(on_startup):
|
||||
while True:
|
||||
try:
|
||||
result = (yield bitcoin_rpc.check_submitblock())
|
||||
if result == True:
|
||||
if result == True:
|
||||
log.info("Found submitblock")
|
||||
elif result == False:
|
||||
log.info("Did not find submitblock")
|
||||
@ -98,7 +98,12 @@ def setup(on_startup):
|
||||
time.sleep(1) # If we didn't get a result or the connect failed
|
||||
|
||||
log.info('Connected to the coind - Begining to load Address and Module Checks!')
|
||||
|
||||
try:
|
||||
if settings.CONFIG_VERSION != 0.1:
|
||||
log.exception("Config File Out OF Date")
|
||||
reactor.stop()
|
||||
except:
|
||||
pass
|
||||
# Start the coinbaser
|
||||
coinbaser = SimpleCoinbaser(bitcoin_rpc, getattr(settings, 'CENTRAL_WALLET'))
|
||||
(yield coinbaser.on_load)
|
||||
|
||||
@ -169,7 +169,7 @@ class MiningService(GenericService):
|
||||
# and it is valid proof of work.
|
||||
try:
|
||||
(block_header, block_hash, share_diff, on_submit) = Interfaces.template_registry.submit_share(job_id,
|
||||
worker_name, session, extranonce1_bin, extranonce2, ntime, nonce, difficulty)
|
||||
worker_name, session, extranonce1_bin, extranonce2, ntime, nonce, difficulty, ip)
|
||||
except SubmitException as e:
|
||||
# block_header and block_hash are None when submitted data are corrupted
|
||||
invalid += 1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user