From 1cf5e15e05596ee4110ff1cdf38b4a1195bcefa2 Mon Sep 17 00:00:00 2001 From: hartland Date: Fri, 27 Dec 2013 12:06:44 -0600 Subject: [PATCH] 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()