1
0

start_interface method

This commit is contained in:
ThomasV
2012-03-23 18:30:06 +01:00
parent a0a67221bb
commit 0532264ff1
3 changed files with 27 additions and 34 deletions

View File

@@ -338,38 +338,13 @@ class AsynchronousInterface(Interface):
def new_interface(wallet):
if wallet.host:
host = wallet.host
else:
host = random.choice( DEFAULT_SERVERS ) # random choice when the wallet is created
port = wallet.port
if port == 50000:
InterfaceClass = NativeInterface
elif port == 50001:
InterfaceClass = AsynchronousInterface
elif port in [80, 81, 8080, 8081]:
InterfaceClass = HttpInterface
else:
print "unknown port number: %d. using native protocol."%port
InterfaceClass = NativeInterface
interface = InterfaceClass(host, port)
return interface
def loop_interfaces_thread(wallet):
while True:
interface = wallet.interface
try:
addresses = wallet.all_addresses()
version = wallet.electrum_version
interface.start_session(addresses, version)
wallet.start_interface()
wallet.run()
print "Disconnected"
except socket.error:
print "socket error"
@@ -379,5 +354,3 @@ def loop_interfaces_thread(wallet):
time.sleep(5)
continue
print "Starting new session: %s:%d"%(wallet.host,wallet.port)
wallet.interface = new_interface(wallet)