From 9f1ed6e8c3e81ef2e9d6adbb0ad6005ee2716f2d Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Tue, 4 Aug 2020 15:02:43 -0400 Subject: [PATCH] release_all_outputs on startup --- lbry/wallet/database.py | 17 ++++++++++------- lbry/wallet/ledger.py | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lbry/wallet/database.py b/lbry/wallet/database.py index 55a10b62b..ebf9745ef 100644 --- a/lbry/wallet/database.py +++ b/lbry/wallet/database.py @@ -1254,13 +1254,16 @@ class Database(SQLiteMixin): self.constrain_collections(constraints) return self.get_utxo_count(**constraints) - async def release_all_outputs(self, account): - await self.db.execute_fetchall( - "UPDATE txo SET is_reserved = 0 WHERE" - " is_reserved = 1 AND txo.address IN (" - " SELECT address from account_address WHERE account = ?" - " )", (account.public_key.address, ) - ) + async def release_all_outputs(self, account=None): + if account is None: + await self.db.execute_fetchall("UPDATE txo SET is_reserved = 0 WHERE is_reserved = 1") + else: + await self.db.execute_fetchall( + "UPDATE txo SET is_reserved = 0 WHERE" + " is_reserved = 1 AND txo.address IN (" + " SELECT address from account_address WHERE account = ?" + " )", (account.public_key.address, ) + ) def get_supports_summary(self, read_only=False, **constraints): return self.get_txos( diff --git a/lbry/wallet/ledger.py b/lbry/wallet/ledger.py index d1a5b69c3..86e3619c3 100644 --- a/lbry/wallet/ledger.py +++ b/lbry/wallet/ledger.py @@ -331,6 +331,7 @@ class Ledger(metaclass=LedgerRegistry): async with self._header_processing_lock: await self._update_tasks.add(self.initial_headers_sync()) await fully_synced + await self.db.release_all_outputs() await asyncio.gather(*(a.maybe_migrate_certificates() for a in self.accounts)) await asyncio.gather(*(a.save_max_gap() for a in self.accounts)) if len(self.accounts) > 10: