mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 12:30:07 +00:00
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
This commit is contained in:
parent
37809bed74
commit
72d06038a7
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue