Two issues surfaced once configure stopped failing:
1. CTxDBBase::NewIterator() was protected, but the snapshot dump/load
code (commits 76579e3, ccfada5) calls it externally. Moved to public —
the iterator interface is intentional public API.
2. RocksDB DB::Open's raw DB** overload was removed in newer releases.
Homebrew's macOS package (10.x) only exposes the std::unique_ptr<DB>*
form; Ubuntu 22.04 (rocksdb 6.x) and MSYS2 (8/9.x) still expose DB**.
Added a SFINAE wrapper OpenSmsgDB() in smessage.cpp that picks
whichever overload the linked rocksdb actually has, so we don't need
version macros or per-distro #ifdefs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
First step of the multi-phase chaindb modernization plan. Introduces a
backend-agnostic abstraction over the chain database:
* CTxDBBase — abstract class owning all serialization and named
operations (ReadTxIndex, WriteBlockIndex, ReadAddressBalance, etc.).
Templated Read/Write/Erase/Exists dispatch to byte-level virtuals
(ReadRaw/WriteRaw/EraseRaw/ExistsRaw) so every backend produces
bit-identical key bytes — required for migration and dual-backend
parity testing later.
* CTxDBIteratorBase — abstract iterator. Backends implement Seek,
Valid, Next, KeyStr, ValueStr.
* CTxDB now inherits from CTxDBBase and only implements the byte-level
I/O, batch lifecycle, NewIterator, and LoadBlockIndex (which still
uses leveldb directly during the v3 dbformat upgrade — extracted to
base in a later phase).
* UTXO read-through cache moved to txdb-base.cpp under an anonymous
namespace — backend-agnostic so RocksDB will get it for free.
* GetAddressUtxos / GetAddressTxIds / SumUtxoValues moved to base,
using NewIterator() instead of pdb->NewIterator().
No call-site changes — every existing CTxDB user keeps working exactly
as before. Stack allocations like `CTxDB txdb("r")` still work because
CTxDB remains a concrete, cheap-to-construct class. Behavior is
bit-identical: same key serialization, same batch semantics, same
LoadBlockIndex flow.
Sets up M1.2 (factory + caller conversion to CTxDBBase&) and M1.3
(RocksDB backend) — neither requires touching consensus paths.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>