Skip to content

Respect read only mode for lmdb databases#4913

Merged
pwojcikdev merged 2 commits intonanocurrency:developfrom
pwojcikdev:refactor-store-read-only
Jun 4, 2025
Merged

Respect read only mode for lmdb databases#4913
pwojcikdev merged 2 commits intonanocurrency:developfrom
pwojcikdev:refactor-store-read-only

Conversation

@pwojcikdev
Copy link
Copy Markdown
Contributor

No description provided.

@pwojcikdev pwojcikdev force-pushed the refactor-store-read-only branch from 8f01bdd to 6183d4e Compare June 3, 2025 17:48
@pwojcikdev pwojcikdev force-pushed the refactor-store-read-only branch from 6183d4e to b17107a Compare June 3, 2025 18:04
@pwojcikdev pwojcikdev requested a review from Copilot June 4, 2025 10:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds support for opening LMDB and RocksDB databases in read-only mode throughout the store component API.

  • Introduce open_mode enum and get_mode() to the store interface.
  • Update LMDB and RocksDB constructors and initialization logic to respect open_mode::read_only.
  • Propagate open_mode from make_store through the node setup and adjust tests for read-only failures.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
nano/store/component.hpp Added open_mode enum and pure virtual get_mode()
nano/store/component.cpp Implemented to_string(open_mode) via enum_util
nano/store/rocksdb/rocksdb.hpp Changed ctor to accept open_mode, added mode field and get_mode()
nano/store/rocksdb/rocksdb.cpp Propagated open_mode to all open() calls, implemented get_mode(), removed old bool API
nano/store/lmdb/lmdb_env.hpp Added options::set_read_only(bool) and read_only flag
nano/store/lmdb/lmdb_env.cpp Honor read_only flag in mdb_env_open, improved error formatting
nano/store/lmdb/lmdb.hpp Changed ctor to accept open_mode, added mode field and get_mode()
nano/store/lmdb/lmdb.cpp Propagated open_mode, guard upgrades in read-only, fixed spelling ("vacuum")
nano/secure/ledger.cpp Throw runtime_error on store init failure
nano/node/node.hpp & node.cpp Reorganized store_impl, wallets*, ledger_impl members, initialize with open_mode
nano/node/make_store.cpp Compute open_mode from flags and pass into LMDB/RocksDB constructors
nano/core_test/node.cpp Adjust read-only failure test to ASSERT_THROW
nano/core_test/block_store.cpp Remove outdated version‐check after init error
Comments suppressed due to low confidence (3)

nano/store/component.hpp:23

  • [nitpick] Add a Doxygen comment above open_mode to describe its purpose and the meaning of its values (read_only vs read_write) to improve maintainability.
enum class open_mode

nano/store/rocksdb/rocksdb.hpp:73

  • [nitpick] Add a brief comment above get_mode() explaining that it returns the current open_mode (read_only/read_write) of the database instance.
nano::store::open_mode get_mode () const override;

nano/core_test/node.cpp:95

  • After asserting that initialization fails in read-only mode, add a test to verify that get_mode() on the store reflects nano::store::open_mode::read_only to ensure the new code path is covered.
ASSERT_THROW (nano::inactive_node (nano::unique_path (), nano::inactive_node_flag_defaults ()), std::runtime_error);

@pwojcikdev pwojcikdev merged commit 986aa92 into nanocurrency:develop Jun 4, 2025
24 of 26 checks passed
@pwojcikdev pwojcikdev deleted the refactor-store-read-only branch June 4, 2025 10:40
pwojcikdev added a commit that referenced this pull request Jun 23, 2025
* Remember store read only status

* Respect read only mode for lmdb databases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants