mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Refactor jtx::Env:
These changes eliminate the Env's OpenLedger member and make transactions go through the Application associated with each instance of the Env, making the unit tests follow a code path closer to the production code path. * Add Env::open() for open ledger * Add Env::now() * Rename to Env::current() * Inject ManualTimeKeeper in Env Application * Make Config mutable * Move setupConfigForUnitTests * Launch Env Application thread * Use Application ledgers in Env * Adjust Application clock on ledger close * Adjust close time for close resolution * Scrub obsolete clock types * Enable features via Env ctor * Make Env::master Account object global * Cache SSL context (performance) * Cache master wallet keys in Ledger ctor (performance)
This commit is contained in:
@@ -286,13 +286,13 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
std::unique_ptr<Config const> config_;
|
||||
std::unique_ptr<Config> config_;
|
||||
std::unique_ptr<Logs> logs_;
|
||||
std::unique_ptr<TimeKeeper> timeKeeper_;
|
||||
|
||||
beast::Journal m_journal;
|
||||
Application::MutexType m_masterMutex;
|
||||
|
||||
std::unique_ptr<TimeKeeper> timeKeeper_;
|
||||
|
||||
// Required by the SHAMapStore
|
||||
TransactionMaster m_txMaster;
|
||||
|
||||
@@ -363,18 +363,17 @@ public:
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
ApplicationImp (
|
||||
std::unique_ptr<Config const> config,
|
||||
std::unique_ptr<Logs> logs)
|
||||
std::unique_ptr<Config> config,
|
||||
std::unique_ptr<Logs> logs,
|
||||
std::unique_ptr<TimeKeeper> timeKeeper)
|
||||
: RootStoppable ("Application")
|
||||
, BasicApp (numberOfThreads(*config))
|
||||
, config_ (std::move(config))
|
||||
, logs_ (std::move(logs))
|
||||
, timeKeeper_ (std::move(timeKeeper))
|
||||
|
||||
, m_journal (logs_->journal("Application"))
|
||||
|
||||
, timeKeeper_ (make_TimeKeeper(
|
||||
logs_->journal("TimeKeeper")))
|
||||
|
||||
, m_txMaster (*this)
|
||||
|
||||
, m_nodeStoreScheduler (*this)
|
||||
@@ -518,8 +517,8 @@ public:
|
||||
return *logs_;
|
||||
}
|
||||
|
||||
Config const&
|
||||
config() const override
|
||||
Config&
|
||||
config() override
|
||||
{
|
||||
return *config_;
|
||||
}
|
||||
@@ -691,6 +690,12 @@ public:
|
||||
return *openLedger_;
|
||||
}
|
||||
|
||||
OpenLedger const&
|
||||
openLedger() const override
|
||||
{
|
||||
return *openLedger_;
|
||||
}
|
||||
|
||||
Overlay& overlay () override
|
||||
{
|
||||
return *m_overlay;
|
||||
@@ -1676,21 +1681,13 @@ Application::Application ()
|
||||
|
||||
std::unique_ptr<Application>
|
||||
make_Application (
|
||||
std::unique_ptr<Config const> config,
|
||||
std::unique_ptr<Logs> logs)
|
||||
std::unique_ptr<Config> config,
|
||||
std::unique_ptr<Logs> logs,
|
||||
std::unique_ptr<TimeKeeper> timeKeeper)
|
||||
{
|
||||
return std::make_unique<ApplicationImp> (
|
||||
std::move(config), std::move(logs));
|
||||
}
|
||||
|
||||
void
|
||||
setupConfigForUnitTests (Config& config)
|
||||
{
|
||||
config.overwrite (ConfigSection::nodeDatabase (), "type", "memory");
|
||||
config.overwrite (ConfigSection::nodeDatabase (), "path", "main");
|
||||
|
||||
config.deprecatedClearSection (ConfigSection::importNodeDatabase ());
|
||||
config.legacy("database_path", "DummyForUnitTests");
|
||||
std::move(config), std::move(logs),
|
||||
std::move(timeKeeper));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user