electrum

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

commit 5e2e82d5166df32e314818da852c0a721554bde4
parent 1fcd8de290abf3094bd04e0a2f5e2df04bcca546
Author: ThomasV <electrumdev@gmail.com>
Date:   Tue,  5 May 2015 12:45:42 +0200

Merge pull request #1189 from kyuupichan/if-cleanup

First of several incremental patches tightening up interface.py.
Diffstat:
Mgui/qt/main_window.py | 2+-
Mlib/interface.py | 25+++++++++++++++----------
Mscripts/servers | 2+-
3 files changed, 17 insertions(+), 12 deletions(-)

diff --git 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 @@ -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: diff --git 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