mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 04:55:52 +00:00
Use injected Logs
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <ripple/app/main/Application.h>
|
||||
#include <ripple/app/tx/InboundTransactions.h>
|
||||
#include <ripple/app/tx/LocalTxs.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/core/Config.h>
|
||||
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
@@ -85,7 +86,7 @@ public:
|
||||
};
|
||||
|
||||
std::unique_ptr<Consensus>
|
||||
make_Consensus (Config const& config);
|
||||
make_Consensus (Config const& config, Logs& logs);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -172,9 +172,9 @@ public:
|
||||
Ledger::Ledger (create_genesis_t, Config const& config, Family& family)
|
||||
: mImmutable (false)
|
||||
, txMap_ (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
||||
family, deprecatedLogs().journal("SHAMap")))
|
||||
family))
|
||||
, stateMap_ (std::make_shared <SHAMap> (SHAMapType::STATE,
|
||||
family, deprecatedLogs().journal("SHAMap")))
|
||||
family))
|
||||
{
|
||||
info_.seq = 1;
|
||||
info_.drops = SYSTEM_CURRENCY_START;
|
||||
@@ -208,10 +208,9 @@ Ledger::Ledger (uint256 const& parentHash,
|
||||
Family& family)
|
||||
: mImmutable (true)
|
||||
, txMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::TRANSACTION, transHash, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
SHAMapType::TRANSACTION, transHash, family))
|
||||
, stateMap_ (std::make_shared <SHAMap> (SHAMapType::STATE, accountHash,
|
||||
family, deprecatedLogs().journal("SHAMap")))
|
||||
family))
|
||||
{
|
||||
info_.seq = ledgerSeq;
|
||||
info_.parentCloseTime = parentCloseTime;
|
||||
@@ -268,7 +267,7 @@ Ledger::Ledger (open_ledger_t, Ledger const& prevLedger,
|
||||
NetClock::time_point closeTime)
|
||||
: mImmutable (false)
|
||||
, txMap_ (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
||||
prevLedger.stateMap_->family(), deprecatedLogs().journal("SHAMap")))
|
||||
prevLedger.stateMap_->family()))
|
||||
, stateMap_ (prevLedger.stateMap_->snapShot (true))
|
||||
, fees_(prevLedger.fees_)
|
||||
{
|
||||
@@ -301,11 +300,9 @@ Ledger::Ledger (void const* data,
|
||||
Config const& config, Family& family)
|
||||
: mImmutable (true)
|
||||
, txMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::TRANSACTION, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
SHAMapType::TRANSACTION, family))
|
||||
, stateMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::STATE, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
SHAMapType::STATE, family))
|
||||
{
|
||||
SerialIter sit (data, size);
|
||||
setRaw (sit, hasPrefix, family);
|
||||
@@ -317,11 +314,9 @@ Ledger::Ledger (std::uint32_t ledgerSeq,
|
||||
Family& family)
|
||||
: mImmutable (false)
|
||||
, txMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::TRANSACTION, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
SHAMapType::TRANSACTION, family))
|
||||
, stateMap_ (std::make_shared <SHAMap> (
|
||||
SHAMapType::STATE, family,
|
||||
deprecatedLogs().journal("SHAMap")))
|
||||
SHAMapType::STATE, family))
|
||||
{
|
||||
info_.seq = ledgerSeq;
|
||||
info_.closeTime = closeTime;
|
||||
@@ -395,9 +390,9 @@ void Ledger::setRaw (SerialIter& sit, bool hasPrefix, Family& family)
|
||||
info_.closeFlags = sit.get8 ();
|
||||
updateHash ();
|
||||
txMap_ = std::make_shared<SHAMap> (SHAMapType::TRANSACTION, info_.txHash,
|
||||
family, deprecatedLogs().journal("SHAMap"));
|
||||
family);
|
||||
stateMap_ = std::make_shared<SHAMap> (SHAMapType::STATE, info_.accountHash,
|
||||
family, deprecatedLogs().journal("SHAMap"));
|
||||
family);
|
||||
}
|
||||
|
||||
void Ledger::addRaw (Serializer& s) const
|
||||
|
||||
@@ -45,9 +45,9 @@ LedgerHistory::LedgerHistory (
|
||||
, collector_ (collector)
|
||||
, mismatch_counter_ (collector->make_counter ("ledger.history", "mismatch"))
|
||||
, m_ledgers_by_hash ("LedgerCache", CACHED_LEDGER_NUM, CACHED_LEDGER_AGE,
|
||||
stopwatch(), deprecatedLogs().journal("TaggedCache"))
|
||||
stopwatch(), app_.logs().journal("TaggedCache"))
|
||||
, m_consensus_validated ("ConsensusValidated", 64, 300,
|
||||
stopwatch(), deprecatedLogs().journal("TaggedCache"))
|
||||
stopwatch(), app_.logs().journal("TaggedCache"))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -21,15 +21,15 @@
|
||||
#include <ripple/app/ledger/LedgerTiming.h>
|
||||
#include <ripple/app/ledger/impl/ConsensusImp.h>
|
||||
#include <ripple/app/ledger/impl/LedgerConsensusImp.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <beast/utility/Journal.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
ConsensusImp::ConsensusImp (FeeVote::Setup const& voteSetup)
|
||||
: journal_ (deprecatedLogs().journal("Consensus"))
|
||||
ConsensusImp::ConsensusImp (
|
||||
FeeVote::Setup const& voteSetup,
|
||||
Logs& logs)
|
||||
: journal_ (logs.journal("Consensus"))
|
||||
, feeVote_ (make_FeeVote (voteSetup,
|
||||
deprecatedLogs().journal("FeeVote")))
|
||||
logs.journal("FeeVote")))
|
||||
, proposing_ (false)
|
||||
, validating_ (false)
|
||||
, lastCloseProposers_ (0)
|
||||
@@ -174,10 +174,11 @@ ConsensusImp::peekStoredProposals ()
|
||||
//==============================================================================
|
||||
|
||||
std::unique_ptr<Consensus>
|
||||
make_Consensus (Config const& config)
|
||||
make_Consensus (Config const& config, Logs& logs)
|
||||
{
|
||||
return std::make_unique<ConsensusImp> (
|
||||
setup_FeeVote (config.section ("voting")));
|
||||
setup_FeeVote (config.section ("voting")),
|
||||
logs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <ripple/app/ledger/Consensus.h>
|
||||
#include <ripple/app/ledger/LedgerConsensus.h>
|
||||
#include <ripple/app/misc/FeeVote.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/protocol/STValidation.h>
|
||||
#include <ripple/shamap/SHAMap.h>
|
||||
#include <beast/utility/Journal.h>
|
||||
@@ -35,7 +36,7 @@ class ConsensusImp
|
||||
: public Consensus
|
||||
{
|
||||
public:
|
||||
ConsensusImp (FeeVote::Setup const& voteSetup);
|
||||
ConsensusImp (FeeVote::Setup const& voteSetup, Logs& logs);
|
||||
|
||||
~ConsensusImp () = default;
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ enum
|
||||
InboundLedger::InboundLedger (
|
||||
Application& app, uint256 const& hash, std::uint32_t seq, fcReason reason, clock_type& clock)
|
||||
: PeerSet (app, hash, ledgerAcquireTimeoutMillis, false, clock,
|
||||
deprecatedLogs().journal("InboundLedger"))
|
||||
app.logs().journal("InboundLedger"))
|
||||
, mHaveHeader (false)
|
||||
, mHaveState (false)
|
||||
, mHaveTransactions (false)
|
||||
|
||||
@@ -1083,7 +1083,7 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
|
||||
|
||||
if (mValidating &&
|
||||
! ledgerMaster_.isCompatible (newLCL,
|
||||
deprecatedLogs().journal("LedgerConsensus").warning,
|
||||
app_.logs().journal("LedgerConsensus").warning,
|
||||
"Not validating"))
|
||||
{
|
||||
mValidating = false;
|
||||
@@ -1424,7 +1424,7 @@ void LedgerConsensusImp::takeInitialPosition (
|
||||
std::shared_ptr<ReadView const> const& initialLedger)
|
||||
{
|
||||
std::shared_ptr<SHAMap> initialSet = std::make_shared <SHAMap> (
|
||||
SHAMapType::TRANSACTION, app_.family(), deprecatedLogs().journal("SHAMap"));
|
||||
SHAMapType::TRANSACTION, app_.family());
|
||||
|
||||
// Build SHAMap containing all transactions in our open ledger
|
||||
for (auto const& tx : initialLedger->txs)
|
||||
@@ -1829,8 +1829,7 @@ applyTransaction (Application& app, OpenView& view,
|
||||
{
|
||||
auto const result = apply(app, view, *txn, flags,
|
||||
app.getHashRouter().sigVerify(),
|
||||
app.config(), deprecatedLogs().
|
||||
journal("LedgerConsensus"));
|
||||
app.config(), app.logs().journal("LedgerConsensus"));
|
||||
if (result.second)
|
||||
{
|
||||
WriteLog (lsDEBUG, LedgerConsensus)
|
||||
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
, mLedgerHistory (collector, app)
|
||||
, mHeldTransactions (uint256 ())
|
||||
, mLedgerCleaner (make_LedgerCleaner (
|
||||
app, *this, deprecatedLogs().journal("LedgerCleaner")))
|
||||
app, *this, app_.logs().journal("LedgerCleaner")))
|
||||
, mMinValidations (0)
|
||||
, mLastValidateSeq (0)
|
||||
, mAdvanceThread (false)
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
, ledger_history_ (app_.config().LEDGER_HISTORY)
|
||||
, ledger_fetch_size_ (app_.config().getSize (siLedgerFetch))
|
||||
, fetch_packs_ ("FetchPack", 65536, 45, stopwatch,
|
||||
deprecatedLogs().journal("TaggedCache"))
|
||||
app_.logs().journal("TaggedCache"))
|
||||
, fetch_seq_ (0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ private:
|
||||
TreeNodeCache treecache_;
|
||||
FullBelowCache fullbelow_;
|
||||
NodeStore::Database& db_;
|
||||
beast::Journal j_;
|
||||
|
||||
// missing node handler
|
||||
std::uint32_t maxSeq = 0;
|
||||
@@ -130,14 +131,21 @@ public:
|
||||
CollectorManager& collectorManager)
|
||||
: app_ (app)
|
||||
, treecache_ ("TreeNodeCache", 65536, 60, stopwatch(),
|
||||
deprecatedLogs().journal("TaggedCache"))
|
||||
app.logs().journal("TaggedCache"))
|
||||
, fullbelow_ ("full_below", stopwatch(),
|
||||
collectorManager.collector(),
|
||||
fullBelowTargetSize, fullBelowExpirationSeconds)
|
||||
, db_ (db)
|
||||
, j_ (app.logs().journal("SHAMap"))
|
||||
{
|
||||
}
|
||||
|
||||
beast::Journal const&
|
||||
journal() override
|
||||
{
|
||||
return j_;
|
||||
}
|
||||
|
||||
FullBelowCache&
|
||||
fullbelow() override
|
||||
{
|
||||
@@ -302,7 +310,7 @@ private:
|
||||
|
||||
public:
|
||||
std::unique_ptr<Config const> config_;
|
||||
Logs& m_logs;
|
||||
std::unique_ptr<Logs> logs_;
|
||||
beast::Journal m_journal;
|
||||
Application::MutexType m_masterMutex;
|
||||
|
||||
@@ -375,16 +383,18 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
ApplicationImp (std::unique_ptr<Config const> config, Logs& logs)
|
||||
ApplicationImp (
|
||||
std::unique_ptr<Config const> config,
|
||||
std::unique_ptr<Logs> logs)
|
||||
: RootStoppable ("Application")
|
||||
, BasicApp (numberOfThreads(*config))
|
||||
, config_ (std::move(config))
|
||||
, m_logs (logs)
|
||||
, logs_ (std::move(logs))
|
||||
|
||||
, m_journal (m_logs.journal("Application"))
|
||||
, m_journal (logs_->journal("Application"))
|
||||
|
||||
, timeKeeper_ (make_TimeKeeper(
|
||||
deprecatedLogs().journal("TimeKeeper")))
|
||||
logs_->journal("TimeKeeper")))
|
||||
|
||||
, m_txMaster (*this)
|
||||
|
||||
@@ -392,7 +402,7 @@ public:
|
||||
|
||||
, m_shaMapStore (make_SHAMapStore (*this, setup_SHAMapStore (*config_),
|
||||
*this, m_nodeStoreScheduler,
|
||||
m_logs.journal ("SHAMapStore"), m_logs.journal ("NodeObject"),
|
||||
logs_->journal ("SHAMapStore"), logs_->journal ("NodeObject"),
|
||||
m_txMaster, *config_))
|
||||
|
||||
, m_nodeStore (m_shaMapStore->makeDatabase ("NodeStore.main", 4))
|
||||
@@ -400,10 +410,10 @@ public:
|
||||
, accountIDCache_(128000)
|
||||
|
||||
, m_tempNodeCache ("NodeCache", 16384, 90, stopwatch(),
|
||||
m_logs.journal("TaggedCache"))
|
||||
logs_->journal("TaggedCache"))
|
||||
|
||||
, m_collectorManager (CollectorManager::New (
|
||||
config_->section (SECTION_INSIGHT), m_logs.journal("Collector")))
|
||||
config_->section (SECTION_INSIGHT), logs_->journal("Collector")))
|
||||
|
||||
, family_ (*this, *m_nodeStore, *m_collectorManager)
|
||||
|
||||
@@ -412,13 +422,13 @@ public:
|
||||
, m_localCredentials (*this)
|
||||
|
||||
, m_resourceManager (Resource::make_Manager (
|
||||
m_collectorManager->collector(), m_logs.journal("Resource")))
|
||||
m_collectorManager->collector(), logs_->journal("Resource")))
|
||||
|
||||
// The JobQueue has to come pretty early since
|
||||
// almost everything is a Stoppable child of the JobQueue.
|
||||
//
|
||||
, m_jobQueue (make_JobQueue (m_collectorManager->group ("jobq"),
|
||||
m_nodeStoreScheduler, m_logs.journal("JobQueue")))
|
||||
m_nodeStoreScheduler, logs_->journal("JobQueue")))
|
||||
|
||||
//
|
||||
// Anything which calls addJob must be a descendant of the JobQueue
|
||||
@@ -427,11 +437,11 @@ public:
|
||||
, m_orderBookDB (*this, *m_jobQueue)
|
||||
|
||||
, m_pathRequests (std::make_unique<PathRequests> (
|
||||
*this, m_logs.journal("PathRequest"), m_collectorManager->collector ()))
|
||||
*this, logs_->journal("PathRequest"), m_collectorManager->collector ()))
|
||||
|
||||
, m_ledgerMaster (make_LedgerMaster (*this, stopwatch (),
|
||||
*m_jobQueue, m_collectorManager->collector (),
|
||||
m_logs.journal("LedgerMaster")))
|
||||
logs_->journal("LedgerMaster")))
|
||||
|
||||
// VFALCO NOTE must come before NetworkOPs to prevent a crash due
|
||||
// to dependencies in the destructor.
|
||||
@@ -450,12 +460,12 @@ public:
|
||||
}))
|
||||
|
||||
, m_acceptedLedgerCache ("AcceptedLedger", 4, 60, stopwatch(),
|
||||
m_logs.journal("TaggedCache"))
|
||||
logs_->journal("TaggedCache"))
|
||||
|
||||
, m_networkOPs (make_NetworkOPs (*this, stopwatch(),
|
||||
config_->RUN_STANDALONE, config_->NETWORK_QUORUM,
|
||||
*m_jobQueue, *m_ledgerMaster, *m_jobQueue,
|
||||
m_logs.journal("NetworkOPs")))
|
||||
logs_->journal("NetworkOPs")))
|
||||
|
||||
// VFALCO NOTE LocalCredentials starts the deprecated UNL service
|
||||
, m_deprecatedUNL (make_UniqueNodeList (*this, *m_jobQueue))
|
||||
@@ -465,16 +475,16 @@ public:
|
||||
|
||||
, m_amendmentTable (make_AmendmentTable
|
||||
(weeks(2), MAJORITY_FRACTION,
|
||||
m_logs.journal("AmendmentTable")))
|
||||
logs_->journal("AmendmentTable")))
|
||||
|
||||
, mFeeTrack (std::make_unique<LoadFeeTrack>(m_logs.journal("LoadManager")))
|
||||
, mFeeTrack (std::make_unique<LoadFeeTrack>(logs_->journal("LoadManager")))
|
||||
|
||||
, mHashRouter (std::make_unique<HashRouter>(
|
||||
HashRouter::getDefaultHoldTime ()))
|
||||
|
||||
, mValidations (make_Validations (*this))
|
||||
|
||||
, m_loadManager (make_LoadManager (*this, *this, m_logs.journal("LoadManager")))
|
||||
, m_loadManager (make_LoadManager (*this, *this, logs_->journal("LoadManager")))
|
||||
|
||||
, m_sweepTimer (this)
|
||||
|
||||
@@ -482,10 +492,10 @@ public:
|
||||
|
||||
, m_signals (get_io_service())
|
||||
|
||||
, m_resolver (ResolverAsio::New (get_io_service(), m_logs.journal("Resolver")))
|
||||
, m_resolver (ResolverAsio::New (get_io_service(), logs_->journal("Resolver")))
|
||||
|
||||
, m_io_latency_sampler (m_collectorManager->collector()->make_event ("ios_latency"),
|
||||
m_logs.journal("Application"), std::chrono::milliseconds (100), get_io_service())
|
||||
logs_->journal("Application"), std::chrono::milliseconds (100), get_io_service())
|
||||
{
|
||||
add (m_resourceManager.get ());
|
||||
|
||||
@@ -551,6 +561,12 @@ public:
|
||||
return *config_;
|
||||
}
|
||||
|
||||
Logs&
|
||||
logs() override
|
||||
{
|
||||
return *logs_;
|
||||
}
|
||||
|
||||
boost::asio::io_service& getIOService () override
|
||||
{
|
||||
return get_io_service();
|
||||
@@ -780,11 +796,11 @@ public:
|
||||
// Let debug messages go to the file but only WARNING or higher to
|
||||
// regular output (unless verbose)
|
||||
|
||||
if (!m_logs.open(debug_log))
|
||||
if (!logs_->open(debug_log))
|
||||
std::cerr << "Can't open log file " << debug_log << '\n';
|
||||
|
||||
if (m_logs.severity() > beast::Journal::kDebug)
|
||||
m_logs.severity (beast::Journal::kDebug);
|
||||
if (logs_->severity() > beast::Journal::kDebug)
|
||||
logs_->severity (beast::Journal::kDebug);
|
||||
}
|
||||
|
||||
if (!config_->RUN_STANDALONE)
|
||||
@@ -1101,8 +1117,6 @@ private:
|
||||
Ledger::pointer getLastFullLedger();
|
||||
bool loadOldLedger (
|
||||
std::string const& ledgerID, bool replay, bool isFilename);
|
||||
|
||||
void onAnnounceAddress ();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -1121,7 +1135,7 @@ void ApplicationImp::startGenesisLedger ()
|
||||
next->setImmutable (*config_);
|
||||
m_networkOPs->setLastCloseTime (next->info().closeTime);
|
||||
openLedger_.emplace(next, *config_,
|
||||
cachedSLEs_, deprecatedLogs().journal("OpenLedger"));
|
||||
cachedSLEs_, logs_->journal("OpenLedger"));
|
||||
m_ledgerMaster->switchLCL (next);
|
||||
}
|
||||
|
||||
@@ -1375,7 +1389,7 @@ bool ApplicationImp::loadOldLedger (
|
||||
m_ledgerMaster->forceValid(loadLedger);
|
||||
m_networkOPs->setLastCloseTime (loadLedger->info().closeTime);
|
||||
openLedger_.emplace(loadLedger, *config_,
|
||||
cachedSLEs_, deprecatedLogs().journal("OpenLedger"));
|
||||
cachedSLEs_, logs_->journal("OpenLedger"));
|
||||
|
||||
if (replay)
|
||||
{
|
||||
@@ -1610,7 +1624,7 @@ void ApplicationImp::updateTables ()
|
||||
NodeStore::DummyScheduler scheduler;
|
||||
std::unique_ptr <NodeStore::Database> source =
|
||||
NodeStore::Manager::instance().make_Database ("NodeStore.import", scheduler,
|
||||
deprecatedLogs().journal("NodeObject"), 0,
|
||||
logs_->journal("NodeObject"), 0,
|
||||
config_->section(ConfigSection::importNodeDatabase ()));
|
||||
|
||||
WriteLog (lsWARNING, NodeObject) <<
|
||||
@@ -1621,11 +1635,6 @@ void ApplicationImp::updateTables ()
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationImp::onAnnounceAddress ()
|
||||
{
|
||||
// NIKB CODEME
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Application::Application ()
|
||||
@@ -1634,10 +1643,12 @@ Application::Application ()
|
||||
}
|
||||
|
||||
std::unique_ptr<Application>
|
||||
make_Application (std::unique_ptr<Config const> config, Logs& logs)
|
||||
make_Application (
|
||||
std::unique_ptr<Config const> config,
|
||||
std::unique_ptr<Logs> logs)
|
||||
{
|
||||
return std::make_unique<ApplicationImp> (
|
||||
std::move(config), logs);
|
||||
std::move(config), std::move(logs));
|
||||
}
|
||||
|
||||
Application& getApp ()
|
||||
|
||||
@@ -91,6 +91,7 @@ public:
|
||||
|
||||
virtual ~Application () = default;
|
||||
virtual Config const& config() const = 0;
|
||||
virtual Logs& logs() = 0;
|
||||
virtual boost::asio::io_service& getIOService () = 0;
|
||||
virtual CollectorManager& getCollectorManager () = 0;
|
||||
virtual Family& family() = 0;
|
||||
@@ -145,7 +146,9 @@ public:
|
||||
};
|
||||
|
||||
std::unique_ptr <Application>
|
||||
make_Application(std::unique_ptr<Config const> config, Logs& logs);
|
||||
make_Application(
|
||||
std::unique_ptr<Config const> config,
|
||||
std::unique_ptr<Logs> logs);
|
||||
|
||||
// DEPRECATED
|
||||
extern Application& getApp ();
|
||||
|
||||
@@ -186,7 +186,9 @@ static int runShutdownTests (std::unique_ptr<Config> config)
|
||||
{
|
||||
std::cerr << "\n\nStarting server. Iteration: " << i << "\n"
|
||||
<< std::endl;
|
||||
auto app = make_Application (std::move(config), deprecatedLogs());
|
||||
auto app = make_Application (
|
||||
std::move(config),
|
||||
std::make_unique<Logs>());
|
||||
auto shutdownApp = [&app](std::chrono::seconds sleepTime, int iteration)
|
||||
{
|
||||
std::this_thread::sleep_for (sleepTime);
|
||||
@@ -210,8 +212,9 @@ static int runUnitTests (
|
||||
// Config needs to be set up before creating Application
|
||||
setupConfigForUnitTests (*config);
|
||||
|
||||
// VFALCO TODO Remove dependence on constructing Application object
|
||||
auto app = make_Application (std::move(config), deprecatedLogs());
|
||||
auto app = make_Application (
|
||||
std::move(config),
|
||||
std::make_unique<Logs>());
|
||||
|
||||
using namespace beast::unit_test;
|
||||
beast::debug_ostream stream;
|
||||
@@ -348,13 +351,6 @@ int run (int argc, char** argv)
|
||||
std::cerr << logMe;
|
||||
}
|
||||
|
||||
if (vm.count ("quiet"))
|
||||
deprecatedLogs().severity(beast::Journal::kFatal);
|
||||
else if (vm.count ("verbose"))
|
||||
deprecatedLogs().severity(beast::Journal::kTrace);
|
||||
else
|
||||
deprecatedLogs().severity(beast::Journal::kInfo);
|
||||
|
||||
// Run the unit tests if requested.
|
||||
// The unit tests will exit the application with an appropriate return code.
|
||||
//
|
||||
@@ -478,10 +474,21 @@ int run (int argc, char** argv)
|
||||
if (vm.count ("shutdowntest"))
|
||||
return runShutdownTests (std::move(config));
|
||||
|
||||
// No arguments. Run server.
|
||||
if (!vm.count ("parameters"))
|
||||
{
|
||||
// No arguments. Run server.
|
||||
auto app = make_Application (std::move(config), deprecatedLogs());
|
||||
auto logs = std::make_unique<Logs>();
|
||||
|
||||
if (vm.count ("quiet"))
|
||||
logs->severity (beast::Journal::kFatal);
|
||||
else if (vm.count ("verbose"))
|
||||
logs->severity (beast::Journal::kTrace);
|
||||
else
|
||||
logs->severity (beast::Journal::kInfo);
|
||||
|
||||
auto app = make_Application (
|
||||
std::move(config),
|
||||
std::move (logs));
|
||||
setupServer (*app);
|
||||
startServer (*app);
|
||||
return 0;
|
||||
|
||||
@@ -116,8 +116,9 @@ public:
|
||||
// VFALCO TODO Make LedgerMaster a SharedPtr or a reference.
|
||||
//
|
||||
NetworkOPsImp (
|
||||
Application& app, clock_type& clock, bool standalone, std::size_t network_quorum,
|
||||
JobQueue& job_queue, LedgerMaster& ledgerMaster, Stoppable& parent,
|
||||
Application& app, clock_type& clock, bool standalone,
|
||||
std::size_t network_quorum, JobQueue& job_queue,
|
||||
LedgerMaster& ledgerMaster, Stoppable& parent,
|
||||
beast::Journal journal)
|
||||
: NetworkOPs (parent)
|
||||
, app_ (app)
|
||||
@@ -129,7 +130,7 @@ public:
|
||||
, m_amendmentBlocked (false)
|
||||
, m_heartbeatTimer (this)
|
||||
, m_clusterTimer (this)
|
||||
, mConsensus (make_Consensus (app_.config()))
|
||||
, mConsensus (make_Consensus (app_.config(), app_.logs()))
|
||||
, m_ledgerMaster (ledgerMaster)
|
||||
, mLastLoadBase (256)
|
||||
, mLastLoadFactor (256)
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
ValidationsImp (Application& app)
|
||||
: app_ (app)
|
||||
, mValidations ("Validations", 128, 600, stopwatch(),
|
||||
deprecatedLogs().journal("TaggedCache"))
|
||||
app.logs().journal("TaggedCache"))
|
||||
, mWriting (false)
|
||||
{
|
||||
mStaleValidations.reserve (512);
|
||||
|
||||
@@ -104,7 +104,7 @@ private:
|
||||
return make_AmendmentTable (
|
||||
weeks (w),
|
||||
majorityFraction,
|
||||
deprecatedLogs().journal("TestAmendmentTable"));
|
||||
beast::Journal{});
|
||||
};
|
||||
|
||||
// Create the amendments by string pairs instead of AmendmentNames
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
{
|
||||
m_zeroSet.mSet = std::make_shared<SHAMap> (
|
||||
SHAMapType::TRANSACTION, uint256(),
|
||||
app_.family(), deprecatedLogs().journal("SHAMap"));
|
||||
app_.family());
|
||||
m_zeroSet.mSet->setUnbacked();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,11 @@ enum
|
||||
|
||||
TransactionAcquire::TransactionAcquire (Application& app, uint256 const& hash, clock_type& clock)
|
||||
: PeerSet (app, hash, TX_ACQUIRE_TIMEOUT, true, clock,
|
||||
deprecatedLogs().journal("TransactionAcquire"))
|
||||
app.logs().journal("TransactionAcquire"))
|
||||
, mHaveRoot (false)
|
||||
{
|
||||
mMap = std::make_shared<SHAMap> (SHAMapType::TRANSACTION, hash,
|
||||
app_.family(), deprecatedLogs().journal("SHAMap"));
|
||||
app_.family());
|
||||
mMap->setUnbacked ();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace ripple {
|
||||
TransactionMaster::TransactionMaster (Application& app)
|
||||
: mApp (app)
|
||||
, mCache ("TransactionCache", 65536, 1800, stopwatch(),
|
||||
deprecatedLogs().journal("TaggedCache"))
|
||||
mApp.logs().journal("TaggedCache"))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
#include <ripple/nodestore/DatabaseRotating.h>
|
||||
#include <ripple/basics/BasicConfig.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <beast/utility/Journal.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
, m_scheduler (scheduler)
|
||||
, m_backend (std::move (backend))
|
||||
, m_cache ("NodeStore", cacheTargetSize, cacheTargetSeconds,
|
||||
stopwatch(), deprecatedLogs().journal("TaggedCache"))
|
||||
stopwatch(), journal)
|
||||
, m_negCache ("NodeStore", stopwatch(),
|
||||
cacheTargetSize, cacheTargetSeconds)
|
||||
, m_readShut (false)
|
||||
|
||||
@@ -53,8 +53,12 @@ public:
|
||||
std::shared_ptr <Backend> writableBackend,
|
||||
std::shared_ptr <Backend> archiveBackend,
|
||||
beast::Journal journal)
|
||||
: DatabaseImp (name, scheduler, readThreads,
|
||||
std::unique_ptr <Backend>(), journal)
|
||||
: DatabaseImp (
|
||||
name,
|
||||
scheduler,
|
||||
readThreads,
|
||||
std::unique_ptr <Backend>(),
|
||||
journal)
|
||||
, writableBackend_ (writableBackend)
|
||||
, archiveBackend_ (archiveBackend)
|
||||
{}
|
||||
|
||||
@@ -93,11 +93,15 @@ ManagerImp::make_Database (
|
||||
int readThreads,
|
||||
Section const& backendParameters)
|
||||
{
|
||||
std::unique_ptr <Backend> backend (make_Backend (
|
||||
backendParameters, scheduler, journal));
|
||||
|
||||
return std::make_unique <DatabaseImp> (name, scheduler, readThreads,
|
||||
std::move (backend), journal);
|
||||
return std::make_unique <DatabaseImp> (
|
||||
name,
|
||||
scheduler,
|
||||
readThreads,
|
||||
make_Backend (
|
||||
backendParameters,
|
||||
scheduler,
|
||||
journal),
|
||||
journal);
|
||||
}
|
||||
|
||||
std::unique_ptr <DatabaseRotating>
|
||||
@@ -109,8 +113,13 @@ ManagerImp::make_DatabaseRotating (
|
||||
std::shared_ptr <Backend> archiveBackend,
|
||||
beast::Journal journal)
|
||||
{
|
||||
return std::make_unique <DatabaseRotatingImp> (name, scheduler,
|
||||
readThreads, writableBackend, archiveBackend, journal);
|
||||
return std::make_unique <DatabaseRotatingImp> (
|
||||
name,
|
||||
scheduler,
|
||||
readThreads,
|
||||
writableBackend,
|
||||
archiveBackend,
|
||||
journal);
|
||||
}
|
||||
|
||||
Factory*
|
||||
|
||||
@@ -139,11 +139,11 @@ OverlayImpl::OverlayImpl (
|
||||
, work_ (boost::in_place(std::ref(io_service_)))
|
||||
, strand_ (io_service_)
|
||||
, setup_(setup)
|
||||
, journal_ (deprecatedLogs().journal("Overlay"))
|
||||
, journal_ (app_.logs().journal("Overlay"))
|
||||
, serverHandler_(serverHandler)
|
||||
, m_resourceManager (resourceManager)
|
||||
, m_peerFinder (PeerFinder::make_Manager (*this, io_service,
|
||||
stopwatch(), deprecatedLogs().journal("PeerFinder"), config))
|
||||
stopwatch(), app_.logs().journal("PeerFinder"), config))
|
||||
, m_resolver (resolver)
|
||||
, next_id_(1)
|
||||
, timer_count_(0)
|
||||
@@ -170,7 +170,7 @@ OverlayImpl::onHandoff (std::unique_ptr <beast::asio::ssl_bundle>&& ssl_bundle,
|
||||
endpoint_type remote_endpoint)
|
||||
{
|
||||
auto const id = next_id_++;
|
||||
beast::WrappedSink sink (deprecatedLogs()["Peer"], makePrefix(id));
|
||||
beast::WrappedSink sink (app_.logs()["Peer"], makePrefix(id));
|
||||
beast::Journal journal (sink);
|
||||
|
||||
Handoff handoff;
|
||||
@@ -356,7 +356,7 @@ OverlayImpl::connect (beast::IP::Endpoint const& remote_endpoint)
|
||||
auto const p = std::make_shared<ConnectAttempt>(app_,
|
||||
io_service_, beast::IPAddressConversion::to_asio_endpoint(remote_endpoint),
|
||||
usage, setup_.context, next_id_++, slot,
|
||||
deprecatedLogs().journal("Peer"), *this);
|
||||
app_.logs().journal("Peer"), *this);
|
||||
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
list_.emplace(p.get(), p);
|
||||
|
||||
@@ -59,8 +59,8 @@ PeerImp::PeerImp (Application& app, id_t id, endpoint_type remote_endpoint,
|
||||
: Child (overlay)
|
||||
, app_ (app)
|
||||
, id_(id)
|
||||
, sink_(deprecatedLogs().journal("Peer"), makePrefix(id))
|
||||
, p_sink_(deprecatedLogs().journal("Protocol"), makePrefix(id))
|
||||
, sink_(app_.logs().journal("Peer"), makePrefix(id))
|
||||
, p_sink_(app_.logs().journal("Protocol"), makePrefix(id))
|
||||
, journal_ (sink_)
|
||||
, p_journal_(p_sink_)
|
||||
, ssl_bundle_(std::move(ssl_bundle))
|
||||
|
||||
@@ -489,8 +489,8 @@ PeerImp::PeerImp (Application& app, std::unique_ptr<beast::asio::ssl_bundle>&& s
|
||||
: Child (overlay)
|
||||
, app_ (app)
|
||||
, id_ (id)
|
||||
, sink_ (deprecatedLogs().journal("Peer"), makePrefix(id))
|
||||
, p_sink_ (deprecatedLogs().journal("Protocol"), makePrefix(id))
|
||||
, sink_ (app_.logs().journal("Peer"), makePrefix(id))
|
||||
, p_sink_ (app_.logs().journal("Protocol"), makePrefix(id))
|
||||
, journal_ (sink_)
|
||||
, p_journal_ (p_sink_)
|
||||
, ssl_bundle_(std::move(ssl_bundle))
|
||||
|
||||
@@ -71,7 +71,7 @@ Json::Value doLedgerRequest (RPC::Context& context)
|
||||
if (ledgerIndex >= ledger->info().seq)
|
||||
return RPC::make_param_error("Ledger index too large");
|
||||
|
||||
auto const j = deprecatedLogs().journal("RPCHandler");
|
||||
auto const j = context.app.logs().journal("RPCHandler");
|
||||
// Try to get the hash of the desired ledger from the validated ledger
|
||||
auto neededHash = hashOfSeq(*ledger, ledgerIndex, j);
|
||||
if (! neededHash)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/app/main/Application.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/json/json_value.h>
|
||||
#include <ripple/net/RPCErr.h>
|
||||
@@ -38,9 +39,9 @@ Json::Value doLogLevel (RPC::Context& context)
|
||||
Json::Value lev (Json::objectValue);
|
||||
|
||||
lev[jss::base] =
|
||||
Logs::toString(Logs::fromSeverity(deprecatedLogs().severity()));
|
||||
Logs::toString(Logs::fromSeverity(context.app.logs().severity()));
|
||||
std::vector< std::pair<std::string, std::string> > logTable (
|
||||
deprecatedLogs().partition_severities());
|
||||
context.app.logs().partition_severities());
|
||||
using stringPair = std::map<std::string, std::string>::value_type;
|
||||
for (auto const& it : logTable)
|
||||
lev[it.first] = it.second;
|
||||
@@ -60,7 +61,7 @@ Json::Value doLogLevel (RPC::Context& context)
|
||||
if (!context.params.isMember (jss::partition))
|
||||
{
|
||||
// set base log severity
|
||||
deprecatedLogs().severity(severity);
|
||||
context.app.logs().severity(severity);
|
||||
return Json::objectValue;
|
||||
}
|
||||
|
||||
@@ -71,9 +72,9 @@ Json::Value doLogLevel (RPC::Context& context)
|
||||
std::string partition (context.params[jss::partition].asString ());
|
||||
|
||||
if (boost::iequals (partition, "base"))
|
||||
deprecatedLogs().severity (severity);
|
||||
context.app.logs().severity (severity);
|
||||
else
|
||||
deprecatedLogs().get(partition).severity(severity);
|
||||
context.app.logs().get(partition).severity(severity);
|
||||
|
||||
return Json::objectValue;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/app/main/Application.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/rpc/impl/Handler.h>
|
||||
|
||||
@@ -25,7 +26,7 @@ namespace ripple {
|
||||
|
||||
Json::Value doLogRotate (RPC::Context& context)
|
||||
{
|
||||
return RPC::makeObjectValue (deprecatedLogs().rotate());
|
||||
return RPC::makeObjectValue (context.app.logs().rotate());
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -61,10 +61,10 @@ ServerHandlerImp::ServerHandlerImp (Application& app, Stoppable& parent,
|
||||
: ServerHandler (parent)
|
||||
, app_ (app)
|
||||
, m_resourceManager (resourceManager)
|
||||
, m_journal (deprecatedLogs().journal("Server"))
|
||||
, m_journal (app_.logs().journal("Server"))
|
||||
, m_networkOPs (networkOPs)
|
||||
, m_server (HTTP::make_Server(
|
||||
*this, io_service, deprecatedLogs().journal("Server")))
|
||||
*this, io_service, app_.logs().journal("Server")))
|
||||
, m_jobQueue (jobQueue)
|
||||
{
|
||||
auto const& group (cm.group ("rpc"));
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <ripple/shamap/FullBelowCache.h>
|
||||
#include <ripple/shamap/TreeNodeCache.h>
|
||||
#include <ripple/nodestore/Database.h>
|
||||
#include <beast/utility/Journal.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace ripple {
|
||||
@@ -32,6 +33,10 @@ class Family
|
||||
public:
|
||||
virtual ~Family() = default;
|
||||
|
||||
virtual
|
||||
beast::Journal const&
|
||||
journal() = 0;
|
||||
|
||||
virtual
|
||||
FullBelowCache&
|
||||
fullbelow() = 0;
|
||||
|
||||
@@ -104,15 +104,13 @@ public:
|
||||
SHAMap (
|
||||
SHAMapType t,
|
||||
Family& f,
|
||||
beast::Journal journal,
|
||||
std::uint32_t seq = 1
|
||||
);
|
||||
|
||||
SHAMap (
|
||||
SHAMapType t,
|
||||
uint256 const& hash,
|
||||
Family& f,
|
||||
beast::Journal journal);
|
||||
Family& f);
|
||||
|
||||
Family&
|
||||
family()
|
||||
|
||||
@@ -26,10 +26,9 @@ namespace ripple {
|
||||
SHAMap::SHAMap (
|
||||
SHAMapType t,
|
||||
Family& f,
|
||||
beast::Journal journal,
|
||||
std::uint32_t seq)
|
||||
: f_ (f)
|
||||
, journal_(journal)
|
||||
, journal_(f.journal())
|
||||
, seq_ (seq)
|
||||
, ledgerSeq_ (0)
|
||||
, state_ (SHAMapState::Modifying)
|
||||
@@ -43,10 +42,9 @@ SHAMap::SHAMap (
|
||||
SHAMap::SHAMap (
|
||||
SHAMapType t,
|
||||
uint256 const& hash,
|
||||
Family& f,
|
||||
beast::Journal journal)
|
||||
Family& f)
|
||||
: f_ (f)
|
||||
, journal_(journal)
|
||||
, journal_(f.journal())
|
||||
, seq_ (1)
|
||||
, ledgerSeq_ (0)
|
||||
, state_ (SHAMapState::Synching)
|
||||
@@ -63,7 +61,7 @@ SHAMap::~SHAMap ()
|
||||
std::shared_ptr<SHAMap>
|
||||
SHAMap::snapShot (bool isMutable) const
|
||||
{
|
||||
auto ret = std::make_shared<SHAMap> (type_, f_, journal_);
|
||||
auto ret = std::make_shared<SHAMap> (type_, f_);
|
||||
SHAMap& newMap = *ret;
|
||||
|
||||
if (!isMutable)
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
beast::Journal const j; // debug journal
|
||||
TestFamily f(j);
|
||||
std::shared_ptr <Table> t1 (std::make_shared <Table> (
|
||||
SHAMapType::FREE, f, beast::Journal()));
|
||||
SHAMapType::FREE, f));
|
||||
|
||||
pass ();
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
h4.SetHex ("b92891fe4ef6cee585fdc6fda2e09eb4d386363158ec3321b8123e5a772c6ca8");
|
||||
h5.SetHex ("a92891fe4ef6cee585fdc6fda0e09eb4d386363158ec3321b8123e5a772c6ca7");
|
||||
|
||||
SHAMap sMap (SHAMapType::FREE, f, beast::Journal());
|
||||
SHAMap sMap (SHAMapType::FREE, f);
|
||||
SHAMapItem i1 (h1, IntToVUC (1)), i2 (h2, IntToVUC (2)), i3 (h3, IntToVUC (3)), i4 (h4, IntToVUC (4)), i5 (h5, IntToVUC (5));
|
||||
unexpected (!sMap.addItem (i2, true, false), "no add");
|
||||
unexpected (!sMap.addItem (i1, true, false), "no add");
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
hashes[6].SetHex ("76DCC77C4027309B5A91AD164083264D70B77B5E43E08AEDA5EBF94361143615");
|
||||
hashes[7].SetHex ("DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA02BBE7230E5");
|
||||
|
||||
SHAMap map (SHAMapType::FREE, f, beast::Journal());
|
||||
SHAMap map (SHAMapType::FREE, f);
|
||||
|
||||
expect (map.getHash() == uint256(), "bad initial empty map hash");
|
||||
for (int i = 0; i < keys.size(); ++i)
|
||||
|
||||
@@ -101,8 +101,8 @@ public:
|
||||
beast::Journal const j; // debug journal
|
||||
|
||||
TestFamily f(j);
|
||||
SHAMap source (SHAMapType::FREE, f, j);
|
||||
SHAMap destination (SHAMapType::FREE, f, j);
|
||||
SHAMap source (SHAMapType::FREE, f);
|
||||
SHAMap destination (SHAMapType::FREE, f);
|
||||
|
||||
int items = 10000;
|
||||
for (int i = 0; i < items; ++i)
|
||||
|
||||
@@ -43,6 +43,7 @@ private:
|
||||
TreeNodeCache treecache_;
|
||||
FullBelowCache fullbelow_;
|
||||
std::unique_ptr<NodeStore::Database> db_;
|
||||
beast::Journal j_;
|
||||
|
||||
public:
|
||||
explicit
|
||||
@@ -63,6 +64,12 @@ public:
|
||||
return clock_;
|
||||
}
|
||||
|
||||
beast::Journal const&
|
||||
journal() override
|
||||
{
|
||||
return j_;
|
||||
}
|
||||
|
||||
FullBelowCache&
|
||||
fullbelow() override
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user