do not queue requests that can be answered using the cache
[electrum-server.git] / processor.py
index 8596625..dfe6128 100644 (file)
@@ -40,6 +40,9 @@ class Processor(threading.Thread):
     def process(self, request):
         pass
 
+    def add_request(self, request):
+        self.queue.put(request)
+
     def push_response(self, response):
         #print "response", response
         self.dispatcher.request_dispatcher.push_response(response)
@@ -162,7 +165,7 @@ class RequestDispatcher(threading.Thread):
             print "error: no processor for", prefix
             return
 
-        p.queue.put(request)
+        p.add_request(request)
 
         if method in ['server.version']:
             session.version = params[0]
@@ -270,9 +273,6 @@ class ResponseDispatcher(threading.Thread):
         method = response.get('method')
         params = response.get('params')
 
-        if method == "blockchain.address.subscribe2":
-            method = "blockchain.address.subscribe"
-
         # A notification
         if internal_id is None: # and method is not None and params is not None:
             self.notification(method, params, response)
@@ -288,6 +288,8 @@ class ResponseDispatcher(threading.Thread):
             if session.stopped():
                 continue
             if session.contains_subscription(subdesc):
+                if response.get('method') == "blockchain.address.subscribe2":
+                    response['method'] = "blockchain.address.subscribe"
                 session.send_response(response)
 
     def send_response(self, internal_id, response):