commit 72d06038a7e0668359f7d3d036c2c3f11193a213
parent 37809bed7459eb7cffff0b1f03954a6b3dc3a616
Author: SomberNight <somber.night@protonmail.com>
Date: Sat, 29 Jun 2019 06:03:14 +0200
synchronizer: fix race in _on_address_status
Triggering needs two consecutive scripthash status changes
in very quick succession. Client gets notification from server,
but then response to "blockchain.scripthash.get_history" will already contain
the changed-again history that has a different status.
20190627T101547.902638Z | INFO | synchronizer.[default_wallet] | receiving history mwXtx49BCGAiy4tU1r7MBX5VVLWSdtasCL 1
20190627T101547.903262Z | INFO | synchronizer.[default_wallet] | error: status mismatch: mwXtx49BCGAiy4tU1r7MBX5VVLWSdtasCL
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/electrum/synchronizer.py b/electrum/synchronizer.py
@@ -147,7 +147,7 @@ class Synchronizer(SynchronizerBase):
def _reset(self):
super()._reset()
self.requested_tx = {}
- self.requested_histories = {}
+ self.requested_histories = set()
def diagnostic_name(self):
return self.wallet.diagnostic_name()
@@ -161,10 +161,10 @@ class Synchronizer(SynchronizerBase):
history = self.wallet.db.get_addr_history(addr)
if history_status(history) == status:
return
- if addr in self.requested_histories:
+ if (addr, status) in self.requested_histories:
return
# request address history
- self.requested_histories[addr] = status
+ self.requested_histories.add((addr, status))
h = address_to_scripthash(addr)
self._requests_sent += 1
result = await self.network.get_history_for_scripthash(h)
@@ -188,7 +188,7 @@ class Synchronizer(SynchronizerBase):
await self._request_missing_txs(hist)
# Remove request; this allows up_to_date to be True
- self.requested_histories.pop(addr)
+ self.requested_histories.discard((addr, status))
async def _request_missing_txs(self, hist, *, allow_server_not_finding_tx=False):
# "hist" is a list of [tx_hash, tx_height] lists