Respect read only mode for lmdb databases#4913
Merged
pwojcikdev merged 2 commits intonanocurrency:developfrom Jun 4, 2025
Merged
Respect read only mode for lmdb databases#4913pwojcikdev merged 2 commits intonanocurrency:developfrom
pwojcikdev merged 2 commits intonanocurrency:developfrom
Conversation
8f01bdd to
6183d4e
Compare
6183d4e to
b17107a
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds support for opening LMDB and RocksDB databases in read-only mode throughout the store component API.
- Introduce
open_modeenum andget_mode()to the store interface. - Update LMDB and RocksDB constructors and initialization logic to respect
open_mode::read_only. - Propagate
open_modefrommake_storethrough 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_modeto describe its purpose and the meaning of its values (read_onlyvsread_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 currentopen_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 reflectsnano::store::open_mode::read_onlyto ensure the new code path is covered.
ASSERT_THROW (nano::inactive_node (nano::unique_path (), nano::inactive_node_flag_defaults ()), std::runtime_error);
pwojcikdev
added a commit
that referenced
this pull request
Jun 23, 2025
* Remember store read only status * Respect read only mode for lmdb databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.