electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 491aab4afc5cf9c3c2937f3344ba69926aee8039
parent 14b5a3afd8b51e7a1133c7c1180bcc73c720ae4a
Author: ThomasV <thomasv@gitorious>
Date:   Tue,  8 Oct 2013 16:52:50 +0200

network.default_server shouldnever be None

Diffstat:
Mlib/network.py | 20+++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/lib/network.py b/lib/network.py @@ -35,8 +35,8 @@ def filter_protocol(servers, p): return l -def pick_random_server(): - return random.choice( filter_protocol(DEFAULT_SERVERS,'s') ) +def pick_random_server(p='s'): + return random.choice( filter_protocol(DEFAULT_SERVERS,p) ) from simple_config import SimpleConfig @@ -50,11 +50,15 @@ class Network(threading.Thread): self.blockchain = Blockchain(self.config, self) self.interfaces = {} self.queue = Queue.Queue() - self.default_server = self.config.get('server') self.callbacks = {} - self.protocol = self.config.get('protocol','s') - self.irc_servers = [] # returned by interface (list from irc) + + # Server for addresses and transactions + self.default_server = self.config.get('server') + if not self.default_server: + self.default_server = pick_random_server(self.protocol) + + self.irc_servers = [] # returned by interface (list from irc) self.disconnected_servers = [] self.recent_servers = self.config.get('recent_servers',[]) # successful connections @@ -149,9 +153,8 @@ class Network(threading.Thread): self.start_interface(server) def start_interfaces(self): - if self.default_server: - self.start_interface(self.default_server) - self.interface = self.interfaces[self.default_server] + self.start_interface(self.default_server) + self.interface = self.interfaces[self.default_server] for i in range(NUM_SERVERS): self.start_random_interface() @@ -188,7 +191,6 @@ class Network(threading.Thread): for i in self.interfaces.values(): i.stop() if auto_connect: self.interface = None - self.default_server = None return if auto_connect: