feat: add NuDB block size tests and improve error handling

Incorporates changes from XRPLF/rippled PR #5468:

- Add getBlockSize() method to Backend interface
  Returns std::optional<std::size_t> for backends that support
  configurable block sizes (currently only NuDB)

- Update parseBlockSize() to throw exceptions instead of warnings
  Invalid block size configurations now throw std::runtime_error
  with descriptive error messages instead of silently using defaults

- Read existing database block size as default
  parseBlockSize() now checks existing nudb.key file for block size
  using nudb::block_size() before applying configuration

- Add comprehensive unit tests (NuDBFactory_test.cpp)
  Tests cover default sizes, valid sizes (4K-32K power-of-2),
  invalid sizes, error messages, power-of-2 validation, and
  data persistence across different block sizes

These changes improve configurability and error reporting while
maintaining backward compatibility.
This commit is contained in:
Nicholas Dudfield
2025-10-22 09:41:30 +07:00
parent d82f74576e
commit 3a18dbcc53
5 changed files with 398 additions and 17 deletions

View File

@@ -1129,9 +1129,8 @@
#
# Optional keys for NuDB only:
#
# nudb_block_size Block size in bytes for NuDB storage.
# Must be a power of 2 between 4096 and 32768.
# Default is 4096.
# nudb_block_size EXPERIMENTAL: Block size in bytes for NuDB storage.
# Must be a power of 2 between 4096 and 32768. Default is 4096.
#
# This parameter controls the fundamental storage unit
# size for NuDB's internal data structures. The choice