network: new trigger 'blockchain_updated'
follow-up af63913189
needed to update history tab when new blocks come,
to refresh the number of confirmations (icons/tooltips)
This commit is contained in:
@@ -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':
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user