First of several incremental patches tightening up interface.py.

Remove some unneeded imports, a constant and a line of dead code.
Document the current external API interface.py provides.
This commit is contained in:
Neil Booth 2015-05-05 14:02:51 +09:00
parent 0a1c8f5546
commit 4d55cb9528
3 changed files with 17 additions and 12 deletions

View File

@ -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

View File

@ -17,28 +17,33 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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:

View File

@ -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