move callbacks to the network class
[electrum-nvc.git] / electrum
index 6128c35..91141ee 100755 (executable)
--- a/electrum
+++ b/electrum
@@ -107,7 +107,6 @@ if __name__ == '__main__':
         util.check_windows_wallet_migration()
 
     config = SimpleConfig(config_options)
-    storage = WalletStorage(config)
 
     if len(args)==0:
         url = None
@@ -129,19 +128,13 @@ if __name__ == '__main__':
             #sys.exit("Error: Unknown GUI: " + gui_name )
         
         # network interface
-        interface = Interface(config, True)
-        interface.start(wait = False)
-        interface.send([('server.peers.subscribe',[])])
-
-        blockchain = BlockchainVerifier(interface, config)
-        blockchain.start()
+        network = Network(config)
+        network.start()
 
-        gui = gui.ElectrumGui(config, interface, blockchain)
+        gui = gui.ElectrumGui(config, network)
         gui.main(url)
         
-        interface.stop()
-        blockchain.stop()
-
+        network.stop()
         # we use daemon threads, their termination is enforced.
         # this sleep command gives them time to terminate cleanly. 
         time.sleep(0.1)
@@ -149,6 +142,7 @@ if __name__ == '__main__':
 
 
     # instanciate wallet for command-line
+    storage = WalletStorage(config)
     wallet = Wallet(storage)
 
     if cmd not in known_commands:
@@ -323,15 +317,13 @@ if __name__ == '__main__':
 
     # open session
     if cmd not in offline_commands and not options.offline:
-        interface = Interface(config)
-        interface.register_callback('connected', lambda: sys.stderr.write("Connected to " + interface.connection_msg + "\n"))
-
-        if not interface.start(wait=True):
+        network = Network(config)
+        network.register_callback('connected', lambda: sys.stderr.write("Connected to " + network.interface.connection_msg + "\n"))
+        if not network.start(wait=True):
             print_msg("Not connected, aborting.")
             sys.exit(1)
-        blockchain = BlockchainVerifier(interface, config)
-        blockchain.start()
-        wallet.start_threads(interface, blockchain)
+
+        wallet.start_threads(network)
         wallet.update()
 
 
@@ -392,7 +384,6 @@ if __name__ == '__main__':
 
     if cmd not in offline_commands and not options.offline:
         wallet.stop_threads()
-        interface.stop()
-        blockchain.stop()
+        network.stop()
         time.sleep(0.1)
         sys.exit(0)