mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Use soci in some places:
* Brings the soci subtree into rippled. * Validator, peerfinder, and SHAMapStore use new soci backend. * Optional postgresql backend for soci (if POSTGRESQL_ROOT env var is set).
This commit is contained in:
@@ -206,24 +206,21 @@ public:
|
||||
boost::asio::basic_waitable_timer<
|
||||
std::chrono::steady_clock> timer_;
|
||||
beast::Journal journal_;
|
||||
beast::File dbFile_;
|
||||
StoreSqdb store_;
|
||||
Logic logic_;
|
||||
SociConfig sociConfig_;
|
||||
|
||||
ManagerImp (Stoppable& parent, boost::asio::io_service& io_service,
|
||||
beast::File const& pathToDbFileOrDirectory, beast::Journal journal)
|
||||
beast::Journal journal, BasicConfig const& config)
|
||||
: Stoppable ("Validators::Manager", parent)
|
||||
, io_service_(io_service)
|
||||
, strand_(io_service_)
|
||||
, timer_(io_service_)
|
||||
, journal_ (journal)
|
||||
, dbFile_ (pathToDbFileOrDirectory)
|
||||
, store_ (journal_)
|
||||
, logic_ (store_, journal_)
|
||||
, sociConfig_ (config, "validators")
|
||||
{
|
||||
if (dbFile_.isDirectory ())
|
||||
dbFile_ = dbFile_.getChildFile("validators.sqlite");
|
||||
|
||||
}
|
||||
|
||||
~ManagerImp()
|
||||
@@ -293,12 +290,8 @@ public:
|
||||
|
||||
void init()
|
||||
{
|
||||
beast::Error error (store_.open (dbFile_));
|
||||
|
||||
if (! error)
|
||||
{
|
||||
logic_.load ();
|
||||
}
|
||||
store_.open (sociConfig_);
|
||||
logic_.load ();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -331,12 +324,11 @@ Manager::Manager ()
|
||||
std::unique_ptr<Manager>
|
||||
make_Manager(beast::Stoppable& parent,
|
||||
boost::asio::io_service& io_service,
|
||||
beast::File const& pathToDbFileOrDirectory,
|
||||
beast::Journal journal)
|
||||
beast::Journal journal,
|
||||
BasicConfig const& config)
|
||||
{
|
||||
return std::make_unique<ManagerImp> (parent,
|
||||
io_service, pathToDbFileOrDirectory, journal);
|
||||
}
|
||||
|
||||
return std::make_unique<ManagerImp>(parent,
|
||||
io_service, journal, config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,19 +35,12 @@ StoreSqdb::~StoreSqdb ()
|
||||
{
|
||||
}
|
||||
|
||||
beast::Error
|
||||
StoreSqdb::open (beast::File const& file)
|
||||
void
|
||||
StoreSqdb::open (SociConfig const& sociConfig)
|
||||
{
|
||||
beast::Error error (m_session.open (file.getFullPathName ()));
|
||||
sociConfig.open (m_session);
|
||||
|
||||
m_journal.info <<
|
||||
"Opening " << file.getFullPathName();
|
||||
|
||||
if (error)
|
||||
m_journal.error <<
|
||||
"Failed opening database: " << error.what();
|
||||
|
||||
return error;
|
||||
m_journal.info << "Opening " << sociConfig.connectionString ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,9 +22,8 @@
|
||||
|
||||
#include <ripple/validators/impl/Store.h>
|
||||
#include <beast/module/core/files/File.h>
|
||||
#include <beast/module/sqdb/sqdb.h>
|
||||
#include <beast/utility/Error.h>
|
||||
#include <beast/utility/Journal.h>
|
||||
#include <ripple/app/data/SociDB.h>
|
||||
|
||||
namespace ripple {
|
||||
namespace Validators {
|
||||
@@ -34,7 +33,7 @@ class StoreSqdb : public Store
|
||||
{
|
||||
private:
|
||||
beast::Journal m_journal;
|
||||
beast::sqdb::session m_session;
|
||||
soci::session m_session;
|
||||
|
||||
public:
|
||||
enum
|
||||
@@ -48,8 +47,8 @@ public:
|
||||
|
||||
~StoreSqdb();
|
||||
|
||||
beast::Error
|
||||
open (beast::File const& file);
|
||||
void
|
||||
open (SociConfig const& sociConfig);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -28,13 +28,14 @@
|
||||
#include <memory>
|
||||
|
||||
namespace ripple {
|
||||
class BasicConfig;
|
||||
namespace Validators {
|
||||
|
||||
std::unique_ptr<Manager>
|
||||
make_Manager (beast::Stoppable& stoppableParent,
|
||||
boost::asio::io_service& io_service,
|
||||
beast::File const& pathToDbFileOrDirectory,
|
||||
beast::Journal journal);
|
||||
beast::Journal journal,
|
||||
BasicConfig const& config);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user