diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 4ec2968ff..ba0de3e23 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -38,7 +38,7 @@ import icons_rc from electrum.util import format_satoshis, format_time, NotEnoughFunds, StoreDict from electrum import Transaction from electrum import mnemonic -from electrum import util, bitcoin, commands, Interface, Wallet +from electrum import util, bitcoin, commands, Wallet from electrum import SimpleConfig, Wallet, WalletStorage from electrum import Imported_Wallet diff --git a/lib/interface.py b/lib/interface.py index 4d22c0b53..0d0338509 100644 --- a/lib/interface.py +++ b/lib/interface.py @@ -17,28 +17,33 @@ # along with this program. If not, see . -import random, ast, re, errno, os -import threading, traceback, sys, time, json, Queue +import re, errno, os +import threading, traceback, sys, time, Queue import socket import ssl +import x509 +import util import requests ca_path = requests.certs.where() from version import ELECTRUM_VERSION, PROTOCOL_VERSION -import util from simple_config import SimpleConfig -import x509 -import util - -DEFAULT_TIMEOUT = 5 - - def Interface(server, config = None): + """Interface factory function. The returned interface class handles the connection + to a single remote electrum server. The object handles all necessary locking. It's + exposed API is: + + - Inherits everything from threading.Thread. + - Member functions start(), send_request(), stop() + - Member variables is_connected, server. + + "is_connected" is currently racy. "server" is constant for the object's lifetime and hence + synchronization is unnecessary. + """ host, port, protocol = server.split(':') - port = int(port) if protocol in 'st': return TcpInterface(server, config) else: diff --git a/scripts/servers b/scripts/servers index 672fdc393..50e581d4d 100755 --- a/scripts/servers +++ b/scripts/servers @@ -1,6 +1,6 @@ #!/usr/bin/env python -from electrum import Interface, SimpleConfig, set_verbosity +from electrum import SimpleConfig, set_verbosity from electrum.network import DEFAULT_SERVERS, filter_protocol import time, Queue from collections import defaultdict