commit 855a70bc6612669138a7f927d7cde9c894a3aab6
parent cbd91ba5b1f9260b40b865180be39be3e63d3112
Author: SomberNight <somber.night@protonmail.com>
Date: Wed, 19 Sep 2018 21:56:09 +0200
network: new trigger 'blockchain_updated'
follow-up af6391318927f7ff686ff70111f9c1e96c38cb2b
needed to update history tab when new blocks come,
to refresh the number of confirmations (icons/tooltips)
Diffstat:
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py
@@ -490,7 +490,8 @@ class ElectrumWindow(App):
activity.bind(on_new_intent=self.on_new_intent)
# connect callbacks
if self.network:
- interests = ['wallet_updated', 'network_updated', 'status', 'new_transaction', 'verified']
+ interests = ['wallet_updated', 'network_updated', 'blockchain_updated',
+ 'status', 'new_transaction', 'verified']
self.network.register_callback(self.on_network_event, interests)
self.network.register_callback(self.on_fee, ['fee'])
self.network.register_callback(self.on_fee_histogram, ['fee_histogram'])
@@ -675,6 +676,9 @@ class ElectrumWindow(App):
elif event == 'wallet_updated':
self._trigger_update_wallet()
self._trigger_update_status()
+ elif event == 'blockchain_updated':
+ # to update number of confirmations in history
+ self._trigger_update_wallet()
elif event == 'status':
self._trigger_update_status()
elif event == 'new_transaction':
diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
@@ -189,7 +189,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
# network callbacks
if self.network:
self.network_signal.connect(self.on_network_qt)
- interests = ['wallet_updated', 'network_updated', 'new_transaction', 'status',
+ interests = ['wallet_updated', 'network_updated', 'blockchain_updated',
+ 'new_transaction', 'status',
'banner', 'verified', 'fee', 'fee_histogram']
# To avoid leaking references to "self" that prevent the
# window from being GC-ed when closed, callbacks should be
@@ -304,6 +305,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.gui_object.network_updated_signal_obj.network_updated_signal \
.emit(event, args)
self.network_signal.emit('status', None)
+ elif event == 'blockchain_updated':
+ # to update number of confirmations in history
+ self.need_update.set()
elif event == 'new_transaction':
wallet, tx = args
if wallet == self.wallet:
diff --git a/electrum/interface.py b/electrum/interface.py
@@ -400,6 +400,7 @@ class Interface(PrintError):
# in the simple case, height == self.tip+1
if height <= self.tip:
await self.sync_until(height)
+ self.network.trigger_callback('blockchain_updated')
async def sync_until(self, height, next_height=None):
if next_height is None:
diff --git a/electrum/network.py b/electrum/network.py
@@ -589,7 +589,9 @@ class Network(PrintError):
i = self.interfaces[server]
if self.interface != i:
self.print_error("switching to", server)
+ blockchain_updated = False
if self.interface is not None:
+ blockchain_updated = i.blockchain != self.interface.blockchain
# Stop any current interface in order to terminate subscriptions,
# and to cancel tasks in interface.group.
# However, for headers sub, give preference to this interface
@@ -605,6 +607,7 @@ class Network(PrintError):
self.trigger_callback('default_server_changed')
self.set_status('connected')
self.trigger_callback('network_updated')
+ if blockchain_updated: self.trigger_callback('blockchain_updated')
@with_interface_lock
def close_interface(self, interface):