Added on_network_block hook to Share manager.
[stratum-mining.git] / mining / subscription.py
index cbbeea5..d04c62e 100644 (file)
@@ -11,14 +11,14 @@ class MiningSubscription(Subscription):
     event = 'mining.notify'
     
     @classmethod
-    def on_block(cls, is_new_block):
+    def on_template(cls, is_new_block):
         '''This is called when TemplateRegistry registers
            new block which we have to broadcast clients.'''
         
         start = Interfaces.timestamper.time()
         
         clean_jobs = is_new_block
-        (job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs) = \
+        (job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, _) = \
                         Interfaces.template_registry.get_last_broadcast_args()
         
         # Push new job to subscribed clients
@@ -30,7 +30,7 @@ class MiningSubscription(Subscription):
     def _finish_after_subscribe(self, result):
         '''Send new job to newly subscribed client'''
         try:        
-            (job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs) = \
+            (job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, _) = \
                         Interfaces.template_registry.get_last_broadcast_args()
         except Exception:
             log.error("Template not ready yet")
@@ -39,10 +39,11 @@ class MiningSubscription(Subscription):
         # Force set higher difficulty
         # TODO
         #self.connection_ref().rpc('mining.set_difficulty', [2,], is_notification=True)
+        #self.connection_ref().rpc('client.get_version', [])
         
         # Force client to remove previous jobs if any (eg. from previous connection)
         clean_jobs = True
-        self.emit_single(job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, clean_jobs)
+        self.emit_single(job_id, prevhash, coinb1, coinb2, merkle_branch, version, nbits, ntime, True)
         
         return result