From 3c03fff3809109db3033cd71f7076056b758921c Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 19 Jan 2022 10:10:24 -0500 Subject: [PATCH] logging, update lbry-rocksdb requirement --- lbry/wallet/__init__.py | 3 ++- lbry/wallet/server/chain_reader.py | 21 ++++----------------- lbry/wallet/server/db/db.py | 3 ++- lbry/wallet/server/db/interface.py | 3 +-- setup.py | 2 +- 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/lbry/wallet/__init__.py b/lbry/wallet/__init__.py index aa1b558b0..cf8e4ad92 100644 --- a/lbry/wallet/__init__.py +++ b/lbry/wallet/__init__.py @@ -10,7 +10,8 @@ from lbry.wallet.wallet import Wallet, WalletStorage, TimestampedPreferences, EN from lbry.wallet.manager import WalletManager from lbry.wallet.network import Network from lbry.wallet.ledger import Ledger, RegTestLedger, TestNetLedger, BlockHeightEvent -from lbry.wallet.account import Account, AddressManager, SingleKey, HierarchicalDeterministic +from lbry.wallet.account import Account, AddressManager, SingleKey, HierarchicalDeterministic, \ + DeterministicChannelKeyManager from lbry.wallet.transaction import Transaction, Output, Input from lbry.wallet.script import OutputScript, InputScript from lbry.wallet.database import SQLiteMixin, Database diff --git a/lbry/wallet/server/chain_reader.py b/lbry/wallet/server/chain_reader.py index 8f722d495..6a99a199b 100644 --- a/lbry/wallet/server/chain_reader.py +++ b/lbry/wallet/server/chain_reader.py @@ -41,14 +41,14 @@ class BlockchainReader: return # if state and self.last_state and self.db.headers and self.last_state.tip == self.db.coin.header_hash(self.db.headers[-1]): # return - if self.last_state and self.last_state.height > state.height: # FIXME: derp - self.log.debug("reorg detected, waiting until the writer has flushed the new blocks to advance") + if self.last_state and self.last_state.height > state.height: + self.log.warning("reorg detected, waiting until the writer has flushed the new blocks to advance") return last_height = 0 if not self.last_state else self.last_state.height if self.last_state: while True: if self.db.headers[-1] == self.db.prefix_db.header.get(last_height, deserialize_value=False): - self.log.debug("connects to block %i", last_height) + self.log.info("connects to block %i", last_height) break else: self.log.warning("disconnect block %i", last_height) @@ -62,22 +62,10 @@ class BlockchainReader: self.clear_caches() self.last_state = state - # elif self.last_state and self.last_state.height > state.height: - # last_height = self.last_state.height - # for height in range(last_height, state.height, -1): - # self.log.warning("unwind %i", height) - # self.unwind() - # self.clear_caches() - # self.last_state = state - # self.log.warning("unwound to %i", self.last_state.height) - - # print("reader rewound to ", self.last_state.height) - async def poll_for_changes(self): await asyncio.get_event_loop().run_in_executor(self._executor, self._detect_changes) async def refresh_blocks_forever(self, synchronized: asyncio.Event): - self.log.info("start refresh blocks forever") while True: try: async with self._lock: @@ -85,7 +73,7 @@ class BlockchainReader: except asyncio.CancelledError: raise except: - self.log.exception("boom") + self.log.exception("blockchain reader main loop encountered an unexpected error") raise await asyncio.sleep(self._refresh_interval) synchronized.set() @@ -161,7 +149,6 @@ class BlockchainReaderServer(BlockchainReader): self.log.info("reader advanced to %i", height) if self._es_height == self.db.db_height: self.synchronized.set() - # print("reader notified") await self.mempool.refresh_hashes(self.db.db_height) self.notifications_to_send.clear() diff --git a/lbry/wallet/server/db/db.py b/lbry/wallet/server/db/db.py index 188e90b01..b8f98344e 100644 --- a/lbry/wallet/server/db/db.py +++ b/lbry/wallet/server/db/db.py @@ -804,7 +804,7 @@ class HubDB: return int(160.6855883050695 * height) def open_db(self): - if self.prefix_db and not self.prefix_db.closed: + if self.prefix_db: return secondary_path = '' if not self._secondary_name else os.path.join( self._db_dir, self._secondary_name @@ -857,6 +857,7 @@ class HubDB: def close(self): self.prefix_db.close() + self.prefix_db = None def get_tx_hash(self, tx_num: int) -> bytes: if self._cache_all_tx_hashes: diff --git a/lbry/wallet/server/db/interface.py b/lbry/wallet/server/db/interface.py index a4066d18d..41899e392 100644 --- a/lbry/wallet/server/db/interface.py +++ b/lbry/wallet/server/db/interface.py @@ -125,8 +125,7 @@ class PrefixDB: ) def close(self): - if not self._db.is_closed: - self._db.close() + self._db.close() def try_catch_up_with_primary(self): self._db.try_catch_up_with_primary() diff --git a/setup.py b/setup.py index 629e45c94..ef0906816 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ with open(os.path.join(BASE, 'README.md'), encoding='utf-8') as fh: ROCKSDB = [] if sys.platform.startswith('linux') or sys.platform.startswith('darwin'): - ROCKSDB.append('lbry-rocksdb==0.8.1') + ROCKSDB.append('lbry-rocksdb==0.8.2') setup(