This commit is contained in:
thomasv 2012-03-14 18:21:27 +01:00
parent 7fd701ea8f
commit 782cd5ea66
1 changed files with 9 additions and 15 deletions

View File

@ -27,7 +27,10 @@ DEFAULT_SERVERS = ['ecdsa.org','electrum.novit.ro'] # list of default servers
class Interface: class Interface:
def __init__(self): def __init__(self, host, port):
self.host = host
self.port = port
self.servers = DEFAULT_SERVERS # actual list from IRC self.servers = DEFAULT_SERVERS # actual list from IRC
self.rtime = 0 self.rtime = 0
self.blocks = 0 self.blocks = 0
@ -59,9 +62,7 @@ class NativeInterface(Interface):
"""This is the original Electrum protocol. It uses polling, and a non-persistent tcp connection""" """This is the original Electrum protocol. It uses polling, and a non-persistent tcp connection"""
def __init__(self, host, port): def __init__(self, host, port):
Interface.__init__(self) Interface.__init__(self, host, port)
self.host = host
self.port = port
def start_session(self, wallet): def start_session(self, wallet):
addresses = wallet.all_addresses() addresses = wallet.all_addresses()
@ -159,7 +160,7 @@ class NativeInterface(Interface):
# if my server is not reachable, I should get the list from one of the default servers # if my server is not reachable, I should get the list from one of the default servers
# requesting servers could be an independent process # requesting servers could be an independent process
while True: while True:
for server in self.default_servers: for server in DEFAULT_SERVERS:
try: try:
self.peers_server = server self.peers_server = server
out = self.handler('peers') out = self.handler('peers')
@ -179,11 +180,6 @@ class NativeInterface(Interface):
class HttpInterface(NativeInterface): class HttpInterface(NativeInterface):
def __init__(self, host, port):
Interface.__init__(self)
self.host = host
self.port = port
def handler(self, method, params = []): def handler(self, method, params = []):
import urllib2, json, time import urllib2, json, time
if type(params) != type([]): params = [ params ] if type(params) != type([]): params = [ params ]
@ -209,12 +205,10 @@ import threading
class TCPInterface(Interface): class TCPInterface(Interface):
"""json-rpc over persistent TCP connection""" """json-rpc over persistent TCP connection"""
def __init__(self, host=None, port=50001): def __init__(self, host, port):
Interface.__init__(self) Interface.__init__(self, host, port)
if host: self.host = host
self.port = 50001
self.tx_event = threading.Event() self.tx_event = threading.Event()
self.addresses_waiting_for_status = [] self.addresses_waiting_for_status = []
self.addresses_waiting_for_history = [] self.addresses_waiting_for_history = []
# up to date # up to date