1
0

address_sync: change up_to_date to be private; no lock needed to read

After some consideration I am fairly certain there is no need to take
wallet.lock in `is_up_to_date()`. Any caller that might want some kind
of guarantees re the value returned by is_up_to_date() would need to
enforce them itself by e.g. taking wallet.lock around its critical code
block. That is, even if is_up_to_date() itself takes the lock, between
the call returning and the caller reading the value there could still
have been a race.
Also, the GUI was directly accessing the field already.
This commit is contained in:
SomberNight
2022-04-08 20:33:13 +02:00
parent 6c05de6fb9
commit 837fc1606c
5 changed files with 13 additions and 13 deletions

View File

@@ -836,7 +836,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
def notify_transactions(self):
if self.tx_notification_queue.qsize() == 0:
return
if not self.wallet.up_to_date:
if not self.wallet.is_up_to_date():
return # no notifications while syncing
now = time.time()
rate_limit = 20 # seconds
@@ -883,7 +883,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
if self.need_update.is_set():
self.need_update.clear()
self.update_wallet()
elif not self.wallet.up_to_date:
elif not self.wallet.is_up_to_date():
# this updates "synchronizing" progress
self.update_status()
# resolve aliases
@@ -977,7 +977,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
# Server height can be 0 after switching to a new server
# until we get a headers subscription request response.
# Display the synchronizing message in that case.
if not self.wallet.up_to_date or server_height == 0:
if not self.wallet.is_up_to_date() or server_height == 0:
num_sent, num_answered = self.wallet.get_history_sync_state_details()
network_text = ("{} ({}/{})"
.format(_("Synchronizing..."), num_answered, num_sent))
@@ -1022,7 +1022,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
def update_wallet(self):
self.update_status()
if self.wallet.up_to_date or not self.network or not self.network.is_connected():
if self.wallet.is_up_to_date() or not self.network or not self.network.is_connected():
self.update_tabs()
def update_tabs(self, wallet=None):