From 1cf5e15e05596ee4110ff1cdf38b4a1195bcefa2 Mon Sep 17 00:00:00 2001 From: hartland Date: Fri, 27 Dec 2013 12:06:44 -0600 Subject: [PATCH 1/3] Add the option to pass scrypt hash to the submit block test --- conf/config_sample.py | 4 ++++ lib/bitcoin_rpc.py | 14 +++++++------- lib/bitcoin_rpc_manager.py | 4 ++-- lib/template_registry.py | 6 +++++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/conf/config_sample.py b/conf/config_sample.py index 5060b0b..855b2b5 100644 --- a/conf/config_sample.py +++ b/conf/config_sample.py @@ -186,3 +186,7 @@ NOTIFY_EMAIL_SERVER = 'localhost' # E-Mail Sender NOTIFY_EMAIL_USERNAME = '' # E-Mail server SMTP Logon NOTIFY_EMAIL_PASSWORD = '' NOTIFY_EMAIL_USETLS = True + +#Pass scrypt hash to submit block check. +#Use if submit block is returning errors and marking submitted blocks invaild upstream, but the submitted blocks are being a accepted by the coin daemon into the block chain. +BLOCK_CHECK_SCRYPT_HASH = False diff --git a/lib/bitcoin_rpc.py b/lib/bitcoin_rpc.py index 3023729..bc36774 100644 --- a/lib/bitcoin_rpc.py +++ b/lib/bitcoin_rpc.py @@ -40,7 +40,7 @@ class BitcoinRPC(object): })) @defer.inlineCallbacks - def submitblock(self, block_hex, block_hash_hex): + def submitblock(self, block_hex, hash_hex): # Try submitblock if that fails, go to getblocktemplate try: log.info("Submitting Block with Submit Block ") @@ -57,7 +57,7 @@ class BitcoinRPC(object): if json.loads(resp)['result'] == None: # make sure the block was created. - defer.returnValue((yield self.blockexists(block_hash_hex))) + defer.returnValue((yield self.blockexists(hash_hex))) else: defer.returnValue(False) @@ -91,12 +91,12 @@ class BitcoinRPC(object): defer.returnValue(json.loads(resp)['result']) @defer.inlineCallbacks - def blockexists(self, block_hash_hex): - resp = (yield self._call('getblock', [block_hash_hex,])) - if "hash" in json.loads(resp)['result'] and json.loads(resp)['result']['hash'] == block_hash_hex: - log.debug("Block Confirmed: %s" % block_hash_hex) + def blockexists(self, hash_hex): + resp = (yield self._call('getblock', [hash_hex,])) + if "hash" in json.loads(resp)['result'] and json.loads(resp)['result']['hash'] == hash_hex: + log.debug("Block Confirmed: %s" % hash_hex) defer.returnValue(True) else: - log.info("Cannot find block for %s" % block_hash_hex) + log.info("Cannot find block for %s" % hash_hex) defer.returnValue(False) diff --git a/lib/bitcoin_rpc_manager.py b/lib/bitcoin_rpc_manager.py index 9977e87..0499c21 100644 --- a/lib/bitcoin_rpc_manager.py +++ b/lib/bitcoin_rpc_manager.py @@ -88,10 +88,10 @@ class BitcoinRPCManager(object): except: self.next_connection() - def submitblock(self, block_hex, block_hash_hex): + def submitblock(self, block_hex, hash_hex): while True: try: - return self.conns[self.curr_conn].submitblock(block_hex, block_hash_hex) + return self.conns[self.curr_conn].submitblock(block_hex, hash_hex) except: self.next_connection() diff --git a/lib/template_registry.py b/lib/template_registry.py index 141c2cf..411c968 100644 --- a/lib/template_registry.py +++ b/lib/template_registry.py @@ -279,7 +279,11 @@ class TemplateRegistry(object): # 7. Submit block to the network serialized = binascii.hexlify(job.serialize()) - on_submit = self.bitcoin_rpc.submitblock(serialized, block_hash_hex) + if settings.BLOCK_CHECK_SCRYPT_HASH: + on_submit = self.bitcoin_rpc.submitblock(serialized, scrypt_hash_hex) + else: + on_submit = self.bitcoin_rpc.submitblock(serialized, block_hash_hex) + if on_submit: self.update_block() From 9db408c6e565d4ab00b4dc6aa84b8917744ee81e Mon Sep 17 00:00:00 2001 From: ahmedbodi Date: Fri, 27 Dec 2013 23:14:16 +0100 Subject: [PATCH 2/3] Formatting --- conf/config_sample.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/config_sample.py b/conf/config_sample.py index 855b2b5..1f2a558 100644 --- a/conf/config_sample.py +++ b/conf/config_sample.py @@ -172,6 +172,10 @@ ALLOW_EXTERNAL_DIFFICULTY = False # For People using the MPOS frontend enabling this is recommended. It allows the frontend to compare the block hash to the coin daemon reducing the liklihood of missing share error's for blocks SOLUTION_BLOCK_HASH = True # If enabled, enter the block hash. If false enter the scrypt/sha hash into the shares table +#Pass scrypt hash to submit block check. +#Use if submit block is returning errors and marking submitted blocks invaild upstream, but the submitted blocks are being a accepted by the coin daemon into the block chain. +BLOCK_CHECK_SCRYPT_HASH = False + # ******************** Worker Ban Options ********************* ENABLE_WORKER_BANNING = True # enable/disable temporary worker banning WORKER_CACHE_TIME = 600 # How long the worker stats cache is good before we check and refresh @@ -186,7 +190,3 @@ NOTIFY_EMAIL_SERVER = 'localhost' # E-Mail Sender NOTIFY_EMAIL_USERNAME = '' # E-Mail server SMTP Logon NOTIFY_EMAIL_PASSWORD = '' NOTIFY_EMAIL_USETLS = True - -#Pass scrypt hash to submit block check. -#Use if submit block is returning errors and marking submitted blocks invaild upstream, but the submitted blocks are being a accepted by the coin daemon into the block chain. -BLOCK_CHECK_SCRYPT_HASH = False From 8e4342076742ec47b8dc3d7dc03017e9f95b0b08 Mon Sep 17 00:00:00 2001 From: ahmedbodi Date: Fri, 27 Dec 2013 23:55:17 +0100 Subject: [PATCH 3/3] Update config_sample.py --- conf/config_sample.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config_sample.py b/conf/config_sample.py index 1f2a558..50beefa 100644 --- a/conf/config_sample.py +++ b/conf/config_sample.py @@ -54,7 +54,7 @@ LOGDIR = 'log/' # Main application log file. LOGFILE = None # eg. 'stratum.log' - +LOGLEVEL = 'DEBUG' # Logging Rotation can be enabled with the following settings # It if not enabled here, you can set up logrotate to rotate the files. # For built in log rotation set LOG_ROTATION = True and configrue the variables