Port UtxoSnapshot::DumpSnapshot to CTxDBBase iterator

DumpSnapshot reached into the LevelDB backend's internal handle via
`extern leveldb::DB *txdb`, which silently broke under -chaindb=rocksdb.
Switched to the backend-agnostic CTxDBBase::NewIterator() interface; the
function now works against either backend.

LoadSnapshot is more involved (writes directly into a fresh txleveldb/
directory) and is bundled with the eventual LevelDB retirement. Added an
IsRocksDbChainBackend() helper and an explicit guard at LoadSnapshot's
entry: refuse to load with a clear error message rather than silently
creating a leveldb tree alongside an active rocksdb chain.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-26 17:43:17 -07:00
parent 426e23d8be
commit 76579e3059
3 changed files with 37 additions and 16 deletions
+5
View File
@@ -62,3 +62,8 @@ std::unique_ptr<CTxDBBase> MakeChainDB(const char* pszMode)
// Unreachable — ResolveChainDbKind throws on bad input.
return nullptr;
}
bool IsRocksDbChainBackend()
{
return ResolveChainDbKind() == ChainDbKind::RocksDB;
}