Skip to content

Commit ae9c2dc

Browse files
committed
feat: enable cache by default
1 parent 4f80786 commit ae9c2dc

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

hathor/builder/cli_builder.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
150150
indexes = RocksDBIndexesManager(self.rocksdb_storage)
151151

152152
kwargs: dict[str, Any] = {}
153-
if not self._args.cache:
153+
if self._args.disable_cache:
154154
# We should only pass indexes if cache is disabled. Otherwise,
155155
# only TransactionCacheStorage should have indexes.
156156
kwargs['indexes'] = indexes
@@ -162,7 +162,8 @@ def create_manager(self, reactor: Reactor) -> HathorManager:
162162

163163
self.log.info('with storage', storage_class=type(tx_storage).__name__, path=self._args.data)
164164
if self._args.cache:
165-
self.check_or_raise(not self._args.memory_storage, '--cache should not be used with --memory-storage')
165+
self.log.warn('--cache is now the default and will be removed')
166+
if not self._args.disable_cache and not self._args.memory_storage:
166167
tx_storage = TransactionCacheStorage(tx_storage, reactor, indexes=indexes, settings=settings)
167168
if self._args.cache_size:
168169
tx_storage.capacity = self._args.cache_size

hathor/cli/run_node.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
from hathor.cli.run_node_args import RunNodeArgs
3030
from hathor.sysctl.runner import SysctlRunner
3131

32+
DEFAULT_CACHE_SIZE: int = 100000
33+
3234

3335
@contextmanager
3436
def temp_fifo(filename: str, tempdir: str | None) -> Iterator[None]:
@@ -116,8 +118,11 @@ def create_parser(cls) -> ArgumentParser:
116118
parser.add_argument('--prometheus', action='store_true', help='Send metric data to Prometheus')
117119
parser.add_argument('--prometheus-prefix', default='',
118120
help='A prefix that will be added in all Prometheus metrics')
119-
parser.add_argument('--cache', action='store_true', help='Use cache for tx storage')
120-
parser.add_argument('--cache-size', type=int, help='Number of txs to keep on cache')
121+
cache_args = parser.add_mutually_exclusive_group()
122+
cache_args.add_argument('--cache', action='store_true', help=SUPPRESS) # moved to --disable-cache
123+
cache_args.add_argument('--disable-cache', action='store_false', help='Disable cache for tx storage')
124+
parser.add_argument('--cache-size', type=int, help='Number of txs to keep on cache',
125+
default=DEFAULT_CACHE_SIZE)
121126
parser.add_argument('--cache-interval', type=int, help='Cache flush interval')
122127
parser.add_argument('--recursion-limit', type=int, help='Set python recursion limit')
123128
parser.add_argument('--allow-mining-without-peers', action='store_true', help='Allow mining without peers')

hathor/cli/run_node_args.py

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class RunNodeArgs(BaseModel, extra=Extra.allow):
5252
prometheus: bool
5353
prometheus_prefix: str
5454
cache: bool
55+
disable_cache: bool
5556
cache_size: Optional[int]
5657
cache_interval: Optional[int]
5758
recursion_limit: Optional[int]

0 commit comments

Comments
 (0)