move init_socket in constructor
[electrum-nvc.git] / lib / interface.py
index 476c9e4..ddb6a0c 100644 (file)
@@ -60,8 +60,6 @@ class InterfaceAncestor(threading.Thread):
         self.responses = Queue.Queue()
         self.unanswered_requests = {}
 
-    def init_socket(self):
-        pass
 
     def poke(self):
         # push a fake response so that the getting thread exits its loop
@@ -210,6 +208,7 @@ class TcpStratumInterface(InterfaceAncestor):
 
     def __init__(self, host, port, proxy=None):
         InterfaceAncestor.__init__(self, host, port, proxy)
+        self.init_socket()
 
     def init_socket(self):
         global proxy_modes
@@ -298,7 +297,7 @@ class Interface(TcpStratumInterface, HttpStratumInterface):
             port = int(port)
 
         self.protocol = protocol
-        proxy = self.parse_proxy_options(config.get('proxy','none'))
+        proxy = self.parse_proxy_options(config.get('proxy'))
         self.server = host + ':%d:%s'%(port, protocol)
 
         #print protocol, host, port
@@ -325,6 +324,7 @@ class Interface(TcpStratumInterface, HttpStratumInterface):
 
 
     def parse_proxy_options(self, s):
+        if type(s) == type({}): return s  # fixme: type should be fixed
         if type(s) != type(""): return None  
         if s.lower() == 'none': return None
         proxy = { "mode":"socks5", "host":"localhost" }
@@ -434,7 +434,6 @@ class WalletSynchronizer(threading.Thread):
 
 
     def start_interface(self):
-        self.interface.init_socket()
         self.interface.start()
         if self.interface.is_connected:
             self.wallet.start_session(self.interface)