diff --git a/lbry/wallet/server/db/db.py b/lbry/wallet/server/db/db.py index 77de9c879..abe8b6388 100644 --- a/lbry/wallet/server/db/db.py +++ b/lbry/wallet/server/db/db.py @@ -22,7 +22,7 @@ from lbry.wallet.server.hash import hash_to_hex_str from lbry.wallet.server.tx import TxInput from lbry.wallet.server.merkle import Merkle, MerkleCache from lbry.wallet.server.db.common import ResolveResult, STREAM_TYPES, CLAIM_TYPES, ExpandedResolveResult, DBError, UTXO -from lbry.wallet.server.db.prefixes import PendingActivationValue, ClaimTakeoverValue, ClaimToTXOValue, HubDB as Prefixes +from lbry.wallet.server.db.prefixes import PendingActivationValue, ClaimTakeoverValue, ClaimToTXOValue, PrefixDB from lbry.wallet.server.db.prefixes import ACTIVATED_CLAIM_TXO_TYPE, ACTIVATED_SUPPORT_TXO_TYPE from lbry.wallet.server.db.prefixes import PendingActivationKey, TXOToClaimValue, DBStatePrefixRow, MempoolTXPrefixRow from lbry.wallet.transaction import OutputScript @@ -59,7 +59,7 @@ class HubDB: if secondary_name: assert max_open_files == -1, 'max open files must be -1 for secondary readers' self._db_max_open_files = max_open_files - self.prefix_db: typing.Optional[Prefixes] = None + self.prefix_db: typing.Optional[PrefixDB] = None self.hist_unflushed = defaultdict(partial(array.array, 'I')) self.hist_unflushed_count = 0 @@ -812,7 +812,7 @@ class HubDB: self._db_dir, self._secondary_name ) db_path = os.path.join(self._db_dir, 'lbry-rocksdb') - self.prefix_db = Prefixes( + self.prefix_db = PrefixDB( db_path, cache_mb=self._cache_MB, reorg_limit=self._reorg_limit, max_open_files=self._db_max_open_files, unsafe_prefixes={DBStatePrefixRow.prefix, MempoolTXPrefixRow.prefix}, secondary_path=secondary_path diff --git a/lbry/wallet/server/db/interface.py b/lbry/wallet/server/db/interface.py index 2786ccf71..79475a240 100644 --- a/lbry/wallet/server/db/interface.py +++ b/lbry/wallet/server/db/interface.py @@ -7,7 +7,7 @@ from lbry.wallet.server.db import DB_PREFIXES from lbry.wallet.server.db.revertable import RevertableOpStack, RevertablePut, RevertableDelete -class PrefixDB: +class BasePrefixDB: """ Base class for a revertable rocksdb database (a rocksdb db where each set of applied changes can be undone) """ diff --git a/lbry/wallet/server/db/prefixes.py b/lbry/wallet/server/db/prefixes.py index 701661ebb..26b105ec0 100644 --- a/lbry/wallet/server/db/prefixes.py +++ b/lbry/wallet/server/db/prefixes.py @@ -4,7 +4,7 @@ import array import base64 from typing import Union, Tuple, NamedTuple, Optional from lbry.wallet.server.db import DB_PREFIXES -from lbry.wallet.server.db.interface import PrefixDB +from lbry.wallet.server.db.interface import BasePrefixDB from lbry.wallet.server.db.common import TrendingNotification from lbry.wallet.server.db.revertable import RevertableOpStack, RevertablePut, RevertableDelete from lbry.schema.url import normalize_name @@ -1742,7 +1742,7 @@ class TouchedHashXPrefixRow(PrefixRow): return cls.pack_key(height), cls.pack_value(touched) -class HubDB(PrefixDB): +class PrefixDB(BasePrefixDB): def __init__(self, path: str, cache_mb: int = 128, reorg_limit: int = 200, max_open_files: int = 512, secondary_path: str = '', unsafe_prefixes: Optional[typing.Set[bytes]] = None): super().__init__(path, max_open_files=max_open_files, secondary_path=secondary_path, diff --git a/lbry/wallet/server/mempool.py b/lbry/wallet/server/mempool.py index ee85ddc82..8b2eb21c4 100644 --- a/lbry/wallet/server/mempool.py +++ b/lbry/wallet/server/mempool.py @@ -17,7 +17,7 @@ from lbry.wallet.server.util import class_logger if typing.TYPE_CHECKING: from lbry.wallet.server.session import LBRYSessionManager - from wallet.server.db.db import LevelDB + from wallet.server.db.db import HubDB @attr.s(slots=True) @@ -49,7 +49,7 @@ mempool_process_time_metric = Histogram( class MemPool: - def __init__(self, coin, db: 'LevelDB', refresh_secs=1.0): + def __init__(self, coin, db: 'HubDB', refresh_secs=1.0): self.coin = coin self._db = db self.logger = class_logger(__name__, self.__class__.__name__) diff --git a/tests/unit/wallet/server/test_revertable.py b/tests/unit/wallet/server/test_revertable.py index 9dbba3220..d04b6dfbb 100644 --- a/tests/unit/wallet/server/test_revertable.py +++ b/tests/unit/wallet/server/test_revertable.py @@ -2,7 +2,7 @@ import unittest import tempfile import shutil from lbry.wallet.server.db.revertable import RevertableOpStack, RevertableDelete, RevertablePut, OpStackIntegrity -from lbry.wallet.server.db.prefixes import ClaimToTXOPrefixRow, HubDB +from lbry.wallet.server.db.prefixes import ClaimToTXOPrefixRow, PrefixDB class TestRevertableOpStack(unittest.TestCase): @@ -107,7 +107,7 @@ class TestRevertableOpStack(unittest.TestCase): class TestRevertablePrefixDB(unittest.TestCase): def setUp(self): self.tmp_dir = tempfile.mkdtemp() - self.db = HubDB(self.tmp_dir, cache_mb=1, max_open_files=32) + self.db = PrefixDB(self.tmp_dir, cache_mb=1, max_open_files=32) def tearDown(self) -> None: self.db.close()