call wallet.wait_until_synchronized before commands

This commit is contained in:
ThomasV 2015-10-29 05:01:06 +01:00
parent b70f8c888a
commit 079cb311ec
5 changed files with 16 additions and 18 deletions

View File

@ -153,7 +153,7 @@ def init_cmdline(config):
wallet.start_threads(network)
print_msg("Recovering wallet...")
wallet.synchronize()
wallet.restore(lambda x: x)
wallet.wait_until_synchronized()
msg = "Recovery successful" if wallet.is_found() else "Found no history for this wallet"
else:
msg = "This wallet was restored offline. It may contain more addresses than displayed."
@ -247,6 +247,7 @@ def run_command(config, network, password):
# start threads
if wallet and network:
wallet.start_threads(network)
wallet.wait_until_synchronized()
# arguments passed to function
args = map(lambda x: config.get(x), cmd.params)
# decode json arguments

View File

@ -953,7 +953,7 @@ class ElectrumGui:
droid.dialogShow()
wallet.start_threads(network)
if action == 'restore':
wallet.restore(lambda x: None)
wallet.wait_until_synchronized()
else:
wallet.synchronize()
droid.dialogDismiss()

View File

@ -1357,8 +1357,8 @@ class ElectrumGui():
dialog.show()
def recover_thread( wallet, dialog ):
wallet.restore(lambda x:x)
GObject.idle_add( dialog.destroy )
wallet.wait_until_synchronized()
GObject.idle_add(dialog.destroy)
thread.start_new_thread( recover_thread, ( wallet, dialog ) )
r = dialog.run()

View File

@ -549,7 +549,7 @@ class InstallWizard(QDialog):
wallet.start_threads(self.network)
if action == 'restore':
self.waiting_dialog(lambda: wallet.restore(self.waiting_label.setText))
self.waiting_dialog(lambda: wallet.wait_until_synchronized(self.waiting_label.setText))
if self.network:
msg = _("Recovery successful") if wallet.is_found() else _("No transactions found for this seed")
else:

View File

@ -314,11 +314,6 @@ class Abstract_Wallet(PrintError):
def is_up_to_date(self):
with self.lock: return self.up_to_date
def update(self):
self.up_to_date = False
while not self.is_up_to_date():
time.sleep(0.1)
def is_imported(self, addr):
account = self.accounts.get(IMPORTED_ACCOUNT)
if account:
@ -1135,21 +1130,23 @@ class Abstract_Wallet(PrintError):
self.verifier = None
self.storage.put('stored_height', self.get_local_height(), True)
def restore(self, callback):
def wait_until_synchronized(self, callback=None):
from i18n import _
def wait_for_wallet():
self.set_up_to_date(False)
while not self.is_up_to_date():
msg = "%s\n%s %d"%(
_("Please wait..."),
_("Addresses generated:"),
len(self.addresses(True)))
apply(callback, (msg,))
if callback:
msg = "%s\n%s %d"%(
_("Please wait..."),
_("Addresses generated:"),
len(self.addresses(True)))
apply(callback, (msg,))
time.sleep(0.1)
def wait_for_network():
while not self.network.is_connected():
msg = "%s \n" % (_("Connecting..."))
apply(callback, (msg,))
if callback:
msg = "%s \n" % (_("Connecting..."))
apply(callback, (msg,))
time.sleep(0.1)
# wait until we are connected, because the user might have selected another server
if self.network: