mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Relational DB interface
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/app/misc/TxQ.h>
|
||||
#include <ripple/basics/mulDiv.h>
|
||||
#include <ripple/core/DatabaseCon.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <ripple/rpc/GRPCHandlers.h>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/app/rdb/RelationalDBInterface_shards.h>
|
||||
#include <ripple/beast/utility/temp_dir.h>
|
||||
#include <ripple/core/ConfigSections.h>
|
||||
#include <ripple/nodestore/DummyScheduler.h>
|
||||
@@ -81,19 +82,14 @@ public:
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(handler->m_);
|
||||
|
||||
auto& session{handler->sqliteDB_->getSession()};
|
||||
|
||||
soci::rowset<soci::row> rs =
|
||||
(session.prepare << "SELECT * FROM State;");
|
||||
|
||||
std::uint64_t rowCount = 0;
|
||||
|
||||
for (auto it = rs.begin(); it != rs.end(); ++it, ++rowCount)
|
||||
{
|
||||
BEAST_EXPECT(it->get<int>(0) == 1);
|
||||
BEAST_EXPECT(it->get<std::string>(1) == rawUrl);
|
||||
}
|
||||
readArchiveDB(
|
||||
*handler->sqlDB_, [&](std::string const& url, int state) {
|
||||
BEAST_EXPECT(state == 1);
|
||||
BEAST_EXPECT(url == rawUrl);
|
||||
++rowCount;
|
||||
});
|
||||
|
||||
BEAST_EXPECT(rowCount == 1);
|
||||
}
|
||||
@@ -136,17 +132,14 @@ public:
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(handler->m_);
|
||||
|
||||
auto& session{handler->sqliteDB_->getSession()};
|
||||
soci::rowset<soci::row> rs =
|
||||
(session.prepare << "SELECT * FROM State;");
|
||||
|
||||
std::uint64_t pos = 0;
|
||||
for (auto it = rs.begin(); it != rs.end(); ++it, ++pos)
|
||||
{
|
||||
BEAST_EXPECT(it->get<int>(0) == dl[pos].first);
|
||||
BEAST_EXPECT(it->get<std::string>(1) == dl[pos].second);
|
||||
}
|
||||
|
||||
readArchiveDB(
|
||||
*handler->sqlDB_, [&](std::string const& url, int state) {
|
||||
BEAST_EXPECT(state == dl[pos].first);
|
||||
BEAST_EXPECT(url == dl[pos].second);
|
||||
++pos;
|
||||
});
|
||||
|
||||
BEAST_EXPECT(pos == dl.size());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/core/DatabaseCon.h>
|
||||
#include <ripple/app/rdb/backend/RelationalDBInterfaceSqlite.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <test/jtx.h>
|
||||
@@ -119,9 +119,9 @@ class Transaction_test : public beast::unit_test::suite
|
||||
const auto deletedLedger = (startLegSeq + endLegSeq) / 2;
|
||||
{
|
||||
// Remove one of the ledgers from the database directly
|
||||
auto db = env.app().getTxnDB().checkoutDb();
|
||||
*db << "DELETE FROM Transactions WHERE LedgerSeq == "
|
||||
<< deletedLedger << ";";
|
||||
dynamic_cast<RelationalDBInterfaceSqlite*>(
|
||||
&env.app().getRelationalDBInterface())
|
||||
->deleteTransactionByLedgerSeq(deletedLedger);
|
||||
}
|
||||
|
||||
for (int deltaEndSeq = 0; deltaEndSeq < 2; ++deltaEndSeq)
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
#include <ripple/app/ledger/LedgerMaster.h>
|
||||
#include <ripple/app/misc/TxQ.h>
|
||||
#include <ripple/app/rdb/backend/RelationalDBInterfaceSqlite.h>
|
||||
#include <ripple/basics/mulDiv.h>
|
||||
#include <ripple/core/DatabaseCon.h>
|
||||
#include <ripple/protocol/ErrorCodes.h>
|
||||
#include <ripple/protocol/jss.h>
|
||||
#include <ripple/rpc/impl/RPCHelpers.h>
|
||||
@@ -769,9 +769,9 @@ class Tx_test : public beast::unit_test::suite
|
||||
const auto deletedLedger = (startLegSeq + endLegSeq) / 2;
|
||||
{
|
||||
// Remove one of the ledgers from the database directly
|
||||
auto db = env.app().getTxnDB().checkoutDb();
|
||||
*db << "DELETE FROM Transactions WHERE LedgerSeq == "
|
||||
<< deletedLedger << ";";
|
||||
dynamic_cast<RelationalDBInterfaceSqlite*>(
|
||||
&env.app().getRelationalDBInterface())
|
||||
->deleteTransactionByLedgerSeq(deletedLedger);
|
||||
}
|
||||
|
||||
for (bool b : {false, true})
|
||||
|
||||
Reference in New Issue
Block a user