electrum

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

commit 8249f5ab67a8fa70cfa2909fec972259fcd2cfc8
parent bfe7e9dc6edba1a308d1199846e8f2d4cd355192
Author: ThomasV <thomasv@electrum.org>
Date:   Mon, 24 Oct 2016 14:57:02 +0200

init_headers in daemon thread, and fix #1996

Diffstat:
Mgui/qt/__init__.py | 8++++++--
Mgui/qt/installwizard.py | 1+
Mlib/blockchain.py | 3++-
Mlib/network.py | 7++++++-
4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py @@ -43,9 +43,9 @@ from electrum.paymentrequest import InvoiceStore from electrum.contacts import Contacts from electrum.synchronizer import Synchronizer from electrum.verifier import SPV -from electrum.util import DebugMem +from electrum.util import DebugMem, UserCancelled from electrum.wallet import Abstract_Wallet -from installwizard import InstallWizard +from installwizard import InstallWizard, GoBack try: @@ -191,6 +191,10 @@ class ElectrumGui: def main(self): try: self.init_network() + except UserCancelled: + return + except GoBack: + return except: traceback.print_exc(file=sys.stdout) return diff --git a/gui/qt/installwizard.py b/gui/qt/installwizard.py @@ -396,6 +396,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard): choices = [_("Auto connect"), _("Select server manually")] title = _("How do you want to connect to a server? ") clayout = ChoicesLayout(message, choices) + self.back_button.setText(_('Cancel')) self.set_main_layout(clayout.layout(), title) r = clayout.selected_index() if r == 0: diff --git a/lib/blockchain.py b/lib/blockchain.py @@ -112,7 +112,8 @@ class Blockchain(util.PrintError): import urllib, socket socket.setdefaulttimeout(30) self.print_error("downloading ", self.headers_url) - urllib.urlretrieve(self.headers_url, filename) + urllib.urlretrieve(self.headers_url, filename + '.tmp') + os.rename(filename + '.tmp', filename) self.print_error("done.") except Exception: self.print_error("download failed. creating file", filename) diff --git a/lib/network.py b/lib/network.py @@ -813,7 +813,12 @@ class Network(util.DaemonThread): self.process_responses(interface) def run(self): - self.blockchain.init() + import threading + t = threading.Thread(target = self.blockchain.init) + t.daemon = True + t.start() + while t.isAlive() and self.is_running(): + t.join(1) while self.is_running(): self.maintain_sockets() self.wait_on_sockets()