3099371864
1. rocksdb::WriteBatch::Handler typeinfo missing on Ubuntu's librocksdb-dev.
Both SecMsgBatchScanner (smessage.cpp) and CRocksBatchScanner
(txdb-rocksdb.cpp) inherited from Handler to scan an active WriteBatch
for pending writes/deletes; that subclass-based scan fails to link
because Ubuntu's package hides the parent's typeinfo. Replaced both
scanners with a parallel std::map<std::string, std::optional<std::string>>
maintained alongside each WriteBatch — Put adds a value entry, Delete
adds a nullopt entry, ScanBatch becomes an O(log n) map lookup. Same
semantics, no Handler dependency.
2. macOS Homebrew's RocksDB 10.x removed the raw DB** overload of
DB::Open; only std::unique_ptr<DB>* remains. txdb-rocksdb.cpp called
the raw form, breaking the macOS build. Added the same SFINAE Open
wrapper used in smessage.cpp (commit 4265343) that picks whichever
overload the linked rocksdb actually has.
3. CSignal<>'s SignalState::slots member collided with Qt's `#define slots`
to empty, stripping the member name in any TU that pulls in <QtCore>
(e.g. moc-generated files that include util_signal.h transitively).
Renamed to slot_map.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
65 lines
2.2 KiB
C++
65 lines
2.2 KiB
C++
// Copyright (c) 2026 The Triangles developers.
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef TRIANGLES_TXDB_ROCKSDB_H
|
|
#define TRIANGLES_TXDB_ROCKSDB_H
|
|
|
|
#include "txdb-base.h"
|
|
|
|
#include <map>
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
#include <rocksdb/db.h>
|
|
#include <rocksdb/options.h>
|
|
#include <rocksdb/write_batch.h>
|
|
|
|
// RocksDB backend for the chain database.
|
|
//
|
|
// Mirrors CTxDB (LevelDB) for byte-level compatibility. CTxDBBase owns all
|
|
// key serialization, so keys produced by this backend are bit-identical to
|
|
// the LevelDB backend. That property is what lets the M1.4 dual-backend
|
|
// parity harness verify equivalence.
|
|
//
|
|
// Data lives under <datadir>/rocksdb/, separate from <datadir>/txleveldb/,
|
|
// so both backends can coexist for migration and side-by-side testing.
|
|
class CRocksTxDB final : public CTxDBBase
|
|
{
|
|
public:
|
|
CRocksTxDB(const char* pszMode = "r+");
|
|
~CRocksTxDB() override;
|
|
|
|
void Close() override;
|
|
|
|
bool TxnBegin() override;
|
|
bool TxnCommit() override;
|
|
bool TxnAbort() override;
|
|
|
|
bool LoadBlockIndex() override;
|
|
|
|
protected:
|
|
bool ReadRaw(const std::string& key, std::string& value) const override;
|
|
bool WriteRaw(const std::string& key, const std::string& value) override;
|
|
bool EraseRaw(const std::string& key) override;
|
|
bool ExistsRaw(const std::string& key) const override;
|
|
std::unique_ptr<CTxDBIteratorBase> NewIterator() const override;
|
|
|
|
private:
|
|
rocksdb::DB* pdb; // Points to the global instance.
|
|
rocksdb::WriteBatch* activeBatch; // When non-NULL, writes/deletes go here.
|
|
rocksdb::Options options;
|
|
int nVersion;
|
|
|
|
// Parallel record of every pending write (value) or delete (nullopt) on
|
|
// activeBatch. Used by ScanBatch to answer "is this key already in the
|
|
// active batch?" without iterating the WriteBatch via Handler — Ubuntu's
|
|
// librocksdb-dev hides typeinfo for rocksdb::WriteBatch::Handler so a
|
|
// subclass-based scan fails to link there.
|
|
std::map<std::string, std::optional<std::string>> pendingBatch;
|
|
|
|
bool ScanBatch(const std::string& key, std::string* value, bool* deleted) const;
|
|
};
|
|
|
|
#endif // TRIANGLES_TXDB_ROCKSDB_H
|