def request(self, *args): if not (self.authorize(args[0], args[1])): log.info("Failed worker authorization: IP %s" % str(ip)) raise SubmitException("Failed worker authorization") session = self.connection_ref().get_session() extranonce1_bin = session.get('extranonce1', None) if not extranonce1_bin: log.info("Connection is not subscribed for mining: IP %s" % str(ip)) raise SubmitException("Connection is not subscribed for mining") extranonce2 = struct.pack('>L', 0) (job_id, prevhash, version, nbits, ntime, _) = Interfaces.template_registry.get_last_broadcast_args() coinbase_bin = Interfaces.template_registry.last_block.serialize_coinbase( extranonce1_bin, extranonce2) coinbase_hash = util.doublesha(coinbase_bin) merkle_root_bin = Interfaces.template_registry.last_block.merkletree.withFirst( coinbase_hash) merkle_root = binascii.hexlify(merkle_root_bin) work_id = Interfaces.worker_manager.register_work( session['extranonce1'], merkle_root, session['difficulty'], job_id, session['basediff']) job = {} job['data'] = version + prevhash + merkle_root + ntime + nbits job['difficulty'] = session['difficulty'] return Pubsub.subscribe(self.connection_ref(), MiningSubscription(), job)
def subscribe(self, *args): '''Subscribe for receiving mining jobs. This will return subscription details, extranonce1_hex and extranonce2_size''' extranonce1 = Interfaces.template_registry.get_new_extranonce1() extranonce2_size = Interfaces.template_registry.extranonce2_size extranonce1_hex = binascii.hexlify(extranonce1) session = self.connection_ref().get_session() session['extranonce1'] = extranonce1 session['difficulty'] = settings.POOL_TARGET # Following protocol specs, default diff is 1 return Pubsub.subscribe(self.connection_ref(), MiningSubscription()) + (extranonce1_hex, extranonce2_size)
def subscribe(self, *args): '''Subscribe for receiving mining jobs. This will return subscription details, extranonce1_hex and extranonce2_size''' extranonce1 = Interfaces.template_registry.get_new_extranonce1() extranonce2_size = Interfaces.template_registry.extranonce2_size extranonce1_hex = binascii.hexlify(extranonce1) session = self.connection_ref().get_session() session['extranonce1'] = extranonce1 if settings.RSK_DEV_MODE and hasattr(settings, 'RSK_STRATUM_DIFFICULTY'): session['difficulty'] = settings.RSK_STRATUM_DIFFICULTY else: session[ 'difficulty'] = 1 # Following protocol specs, default diff is 1 return Pubsub.subscribe( self.connection_ref(), MiningSubscription()) + (extranonce1_hex, extranonce2_size)
def subscribe(self, *args): '''Subscribe for receiving mining jobs. This will return subscription details, extranonce1_hex and extranonce2_size''' try: log.debug("Subscribed: %s" % str(args[0])) except: log.debug("Subscribed: uknown") extranonce1 = Interfaces.template_registry.get_new_extranonce1() extranonce2_size = Interfaces.template_registry.extranonce2_size extranonce1_hex = binascii.hexlify(extranonce1) session = self.connection_ref().get_session() log.debug("Subscribed Session: %s" % session) session['extranonce1'] = extranonce1 session['difficulty'] = settings.POOL_TARGET # Following protocol specs, default diff is 1 log.info("Initial subscribed worker difficulty set to: %s" % session['difficulty']) return Pubsub.subscribe(self.connection_ref(), MiningSubscription()) + (extranonce1_hex, extranonce2_size)
if (failure == 1): log.error("Problems with Coind %s, retry in 30 sec" % wallet) yield sleep(29) wallet_connect(wallet, bitcoin_rpc) log.info( 'Connected to the coind - Begining to load Address and Module Checks!') # Start the coinbaser coinbaser = SimpleCoinbaser(bitcoin_rpc, wallet) log.info('Starting registry') (yield coinbaser.on_load) log.info('Starting registry') mining_subscription = MiningSubscription() mining_subscription.wallet = wallet registry = TemplateRegistry(wallet, BlockTemplate, coinbaser, bitcoin_rpc, getattr(settings, 'INSTANCE_ID'), mining_subscription.on_template, Interfaces.share_manager.on_network_block) log.info('Set template registry for %s' % wallet) # Template registry is the main interface between Stratum service # and pool core logic #Interfaces.set_template_registry(registry) Interfaces.add_template_registry(wallet, registry) log.info('Block updater')