diff --git a/src/ripple/app/ledger/Consensus.h b/src/ripple/app/ledger/Consensus.h index 7d329088a4..5bd534cfa5 100644 --- a/src/ripple/app/ledger/Consensus.h +++ b/src/ripple/app/ledger/Consensus.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include // @@ -85,7 +86,7 @@ public: }; std::unique_ptr -make_Consensus (Config const& config); +make_Consensus (Config const& config, Logs& logs); } diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 95d7db431c..420f5fbc98 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -172,9 +172,9 @@ public: Ledger::Ledger (create_genesis_t, Config const& config, Family& family) : mImmutable (false) , txMap_ (std::make_shared (SHAMapType::TRANSACTION, - family, deprecatedLogs().journal("SHAMap"))) + family)) , stateMap_ (std::make_shared (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 ( - SHAMapType::TRANSACTION, transHash, family, - deprecatedLogs().journal("SHAMap"))) + SHAMapType::TRANSACTION, transHash, family)) , stateMap_ (std::make_shared (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 (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 ( - SHAMapType::TRANSACTION, family, - deprecatedLogs().journal("SHAMap"))) + SHAMapType::TRANSACTION, family)) , stateMap_ (std::make_shared ( - 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 ( - SHAMapType::TRANSACTION, family, - deprecatedLogs().journal("SHAMap"))) + SHAMapType::TRANSACTION, family)) , stateMap_ (std::make_shared ( - 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 (SHAMapType::TRANSACTION, info_.txHash, - family, deprecatedLogs().journal("SHAMap")); + family); stateMap_ = std::make_shared (SHAMapType::STATE, info_.accountHash, - family, deprecatedLogs().journal("SHAMap")); + family); } void Ledger::addRaw (Serializer& s) const diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/ripple/app/ledger/LedgerHistory.cpp index a63150ade9..64edcc4a28 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/ripple/app/ledger/LedgerHistory.cpp @@ -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")) { } diff --git a/src/ripple/app/ledger/impl/ConsensusImp.cpp b/src/ripple/app/ledger/impl/ConsensusImp.cpp index addeddbb86..18a0e5d5db 100644 --- a/src/ripple/app/ledger/impl/ConsensusImp.cpp +++ b/src/ripple/app/ledger/impl/ConsensusImp.cpp @@ -21,15 +21,15 @@ #include #include #include -#include -#include 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 -make_Consensus (Config const& config) +make_Consensus (Config const& config, Logs& logs) { return std::make_unique ( - setup_FeeVote (config.section ("voting"))); + setup_FeeVote (config.section ("voting")), + logs); } } diff --git a/src/ripple/app/ledger/impl/ConsensusImp.h b/src/ripple/app/ledger/impl/ConsensusImp.h index 26ab2ae2e3..f5c799e91a 100644 --- a/src/ripple/app/ledger/impl/ConsensusImp.h +++ b/src/ripple/app/ledger/impl/ConsensusImp.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,7 @@ class ConsensusImp : public Consensus { public: - ConsensusImp (FeeVote::Setup const& voteSetup); + ConsensusImp (FeeVote::Setup const& voteSetup, Logs& logs); ~ConsensusImp () = default; diff --git a/src/ripple/app/ledger/impl/InboundLedger.cpp b/src/ripple/app/ledger/impl/InboundLedger.cpp index fe1ec63800..1fbcdb3248 100644 --- a/src/ripple/app/ledger/impl/InboundLedger.cpp +++ b/src/ripple/app/ledger/impl/InboundLedger.cpp @@ -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) diff --git a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp index 8583bf4bb5..de1580af00 100644 --- a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp +++ b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp @@ -1083,7 +1083,7 @@ void LedgerConsensusImp::accept (std::shared_ptr 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 const& initialLedger) { std::shared_ptr initialSet = std::make_shared ( - 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) diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index ea5cdccb2f..8088869209 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -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) { } diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 539d32c49e..b5d8f4e154 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -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_; - Logs& m_logs; + std::unique_ptr logs_; beast::Journal m_journal; Application::MutexType m_masterMutex; @@ -375,16 +383,18 @@ public: //-------------------------------------------------------------------------- - ApplicationImp (std::unique_ptr config, Logs& logs) + ApplicationImp ( + std::unique_ptr config, + std::unique_ptr 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 ( - *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(m_logs.journal("LoadManager"))) + , mFeeTrack (std::make_unique(logs_->journal("LoadManager"))) , mHashRouter (std::make_unique( 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 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 -make_Application (std::unique_ptr config, Logs& logs) +make_Application ( + std::unique_ptr config, + std::unique_ptr logs) { return std::make_unique ( - std::move(config), logs); + std::move(config), std::move(logs)); } Application& getApp () diff --git a/src/ripple/app/main/Application.h b/src/ripple/app/main/Application.h index ad49368fc9..0e844c7074 100644 --- a/src/ripple/app/main/Application.h +++ b/src/ripple/app/main/Application.h @@ -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 -make_Application(std::unique_ptr config, Logs& logs); +make_Application( + std::unique_ptr config, + std::unique_ptr logs); // DEPRECATED extern Application& getApp (); diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index 80432a5c93..5709c9c805 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -186,7 +186,9 @@ static int runShutdownTests (std::unique_ptr 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()); 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()); 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(); + + 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; diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 23b4882e83..475943dde8 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -116,9 +116,10 @@ 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, - beast::Journal journal) + 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) , m_clock (clock) @@ -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) diff --git a/src/ripple/app/misc/Validations.cpp b/src/ripple/app/misc/Validations.cpp index 7ef95d13de..6e5041aead 100644 --- a/src/ripple/app/misc/Validations.cpp +++ b/src/ripple/app/misc/Validations.cpp @@ -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); diff --git a/src/ripple/app/tests/AmendmentTable.test.cpp b/src/ripple/app/tests/AmendmentTable.test.cpp index cc6a2647b5..a8345b13e8 100644 --- a/src/ripple/app/tests/AmendmentTable.test.cpp +++ b/src/ripple/app/tests/AmendmentTable.test.cpp @@ -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 diff --git a/src/ripple/app/tx/impl/InboundTransactions.cpp b/src/ripple/app/tx/impl/InboundTransactions.cpp index d0881d8900..d6586c64da 100644 --- a/src/ripple/app/tx/impl/InboundTransactions.cpp +++ b/src/ripple/app/tx/impl/InboundTransactions.cpp @@ -82,7 +82,7 @@ public: { m_zeroSet.mSet = std::make_shared ( SHAMapType::TRANSACTION, uint256(), - app_.family(), deprecatedLogs().journal("SHAMap")); + app_.family()); m_zeroSet.mSet->setUnbacked(); } diff --git a/src/ripple/app/tx/impl/TransactionAcquire.cpp b/src/ripple/app/tx/impl/TransactionAcquire.cpp index 91b905da1c..8f292aa02e 100644 --- a/src/ripple/app/tx/impl/TransactionAcquire.cpp +++ b/src/ripple/app/tx/impl/TransactionAcquire.cpp @@ -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 (SHAMapType::TRANSACTION, hash, - app_.family(), deprecatedLogs().journal("SHAMap")); + app_.family()); mMap->setUnbacked (); } diff --git a/src/ripple/app/tx/impl/TransactionMaster.cpp b/src/ripple/app/tx/impl/TransactionMaster.cpp index 8d07a568a8..b382dec051 100644 --- a/src/ripple/app/tx/impl/TransactionMaster.cpp +++ b/src/ripple/app/tx/impl/TransactionMaster.cpp @@ -28,7 +28,7 @@ namespace ripple { TransactionMaster::TransactionMaster (Application& app) : mApp (app) , mCache ("TransactionCache", 65536, 1800, stopwatch(), - deprecatedLogs().journal("TaggedCache")) + mApp.logs().journal("TaggedCache")) { } diff --git a/src/ripple/nodestore/Manager.h b/src/ripple/nodestore/Manager.h index 9ee13f9994..4987bc2b6e 100644 --- a/src/ripple/nodestore/Manager.h +++ b/src/ripple/nodestore/Manager.h @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace ripple { diff --git a/src/ripple/nodestore/impl/DatabaseImp.h b/src/ripple/nodestore/impl/DatabaseImp.h index c62b7aca73..2e586c7554 100644 --- a/src/ripple/nodestore/impl/DatabaseImp.h +++ b/src/ripple/nodestore/impl/DatabaseImp.h @@ -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) diff --git a/src/ripple/nodestore/impl/DatabaseRotatingImp.h b/src/ripple/nodestore/impl/DatabaseRotatingImp.h index ad0165db83..a2645f3807 100644 --- a/src/ripple/nodestore/impl/DatabaseRotatingImp.h +++ b/src/ripple/nodestore/impl/DatabaseRotatingImp.h @@ -53,8 +53,12 @@ public: std::shared_ptr writableBackend, std::shared_ptr archiveBackend, beast::Journal journal) - : DatabaseImp (name, scheduler, readThreads, - std::unique_ptr (), journal) + : DatabaseImp ( + name, + scheduler, + readThreads, + std::unique_ptr (), + journal) , writableBackend_ (writableBackend) , archiveBackend_ (archiveBackend) {} diff --git a/src/ripple/nodestore/impl/ManagerImp.cpp b/src/ripple/nodestore/impl/ManagerImp.cpp index f0d5f093b5..f4e9e4cef5 100644 --- a/src/ripple/nodestore/impl/ManagerImp.cpp +++ b/src/ripple/nodestore/impl/ManagerImp.cpp @@ -93,11 +93,15 @@ ManagerImp::make_Database ( int readThreads, Section const& backendParameters) { - std::unique_ptr backend (make_Backend ( - backendParameters, scheduler, journal)); - - return std::make_unique (name, scheduler, readThreads, - std::move (backend), journal); + return std::make_unique ( + name, + scheduler, + readThreads, + make_Backend ( + backendParameters, + scheduler, + journal), + journal); } std::unique_ptr @@ -109,8 +113,13 @@ ManagerImp::make_DatabaseRotating ( std::shared_ptr archiveBackend, beast::Journal journal) { - return std::make_unique (name, scheduler, - readThreads, writableBackend, archiveBackend, journal); + return std::make_unique ( + name, + scheduler, + readThreads, + writableBackend, + archiveBackend, + journal); } Factory* diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index bd65c8afc7..cafa80846f 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -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 && 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(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 lock(mutex_); list_.emplace(p.get(), p); diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index b59980f2ff..283ef83828 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -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)) diff --git a/src/ripple/overlay/impl/PeerImp.h b/src/ripple/overlay/impl/PeerImp.h index c16460ebbc..d2c8b87a3e 100644 --- a/src/ripple/overlay/impl/PeerImp.h +++ b/src/ripple/overlay/impl/PeerImp.h @@ -489,8 +489,8 @@ PeerImp::PeerImp (Application& app, std::unique_ptr&& 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)) diff --git a/src/ripple/rpc/handlers/LedgerRequest.cpp b/src/ripple/rpc/handlers/LedgerRequest.cpp index e6885a4a29..b80fcee9fc 100644 --- a/src/ripple/rpc/handlers/LedgerRequest.cpp +++ b/src/ripple/rpc/handlers/LedgerRequest.cpp @@ -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) diff --git a/src/ripple/rpc/handlers/LogLevel.cpp b/src/ripple/rpc/handlers/LogLevel.cpp index 071a2ec211..9311837f97 100644 --- a/src/ripple/rpc/handlers/LogLevel.cpp +++ b/src/ripple/rpc/handlers/LogLevel.cpp @@ -18,6 +18,7 @@ //============================================================================== #include +#include #include #include #include @@ -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 > logTable ( - deprecatedLogs().partition_severities()); + context.app.logs().partition_severities()); using stringPair = std::map::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; } diff --git a/src/ripple/rpc/handlers/LogRotate.cpp b/src/ripple/rpc/handlers/LogRotate.cpp index 15df6a0d8e..d86638bd47 100644 --- a/src/ripple/rpc/handlers/LogRotate.cpp +++ b/src/ripple/rpc/handlers/LogRotate.cpp @@ -18,6 +18,7 @@ //============================================================================== #include +#include #include #include @@ -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 diff --git a/src/ripple/server/impl/ServerHandlerImp.cpp b/src/ripple/server/impl/ServerHandlerImp.cpp index f868777410..1dac0a9e62 100644 --- a/src/ripple/server/impl/ServerHandlerImp.cpp +++ b/src/ripple/server/impl/ServerHandlerImp.cpp @@ -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")); diff --git a/src/ripple/shamap/Family.h b/src/ripple/shamap/Family.h index af112a5f73..7c23e113f4 100644 --- a/src/ripple/shamap/Family.h +++ b/src/ripple/shamap/Family.h @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace ripple { @@ -32,6 +33,10 @@ class Family public: virtual ~Family() = default; + virtual + beast::Journal const& + journal() = 0; + virtual FullBelowCache& fullbelow() = 0; diff --git a/src/ripple/shamap/SHAMap.h b/src/ripple/shamap/SHAMap.h index 09e8796b9c..f2fb70f61d 100644 --- a/src/ripple/shamap/SHAMap.h +++ b/src/ripple/shamap/SHAMap.h @@ -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() diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index 7b5cb15c00..09a3434f5c 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -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::snapShot (bool isMutable) const { - auto ret = std::make_shared (type_, f_, journal_); + auto ret = std::make_shared (type_, f_); SHAMap& newMap = *ret; if (!isMutable) diff --git a/src/ripple/shamap/tests/FetchPack.test.cpp b/src/ripple/shamap/tests/FetchPack.test.cpp index 3096d67ab1..2a074c3a3b 100644 --- a/src/ripple/shamap/tests/FetchPack.test.cpp +++ b/src/ripple/shamap/tests/FetchPack.test.cpp @@ -117,7 +117,7 @@ public: beast::Journal const j; // debug journal TestFamily f(j); std::shared_ptr t1 (std::make_shared
( - SHAMapType::FREE, f, beast::Journal())); + SHAMapType::FREE, f)); pass (); diff --git a/src/ripple/shamap/tests/SHAMap.test.cpp b/src/ripple/shamap/tests/SHAMap.test.cpp index 18557ad4e9..eaa2df4add 100644 --- a/src/ripple/shamap/tests/SHAMap.test.cpp +++ b/src/ripple/shamap/tests/SHAMap.test.cpp @@ -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) diff --git a/src/ripple/shamap/tests/SHAMapSync.test.cpp b/src/ripple/shamap/tests/SHAMapSync.test.cpp index fe712e23e9..094641b0da 100644 --- a/src/ripple/shamap/tests/SHAMapSync.test.cpp +++ b/src/ripple/shamap/tests/SHAMapSync.test.cpp @@ -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) diff --git a/src/ripple/shamap/tests/common.h b/src/ripple/shamap/tests/common.h index 92d50bca97..e58af676ee 100644 --- a/src/ripple/shamap/tests/common.h +++ b/src/ripple/shamap/tests/common.h @@ -43,6 +43,7 @@ private: TreeNodeCache treecache_; FullBelowCache fullbelow_; std::unique_ptr db_; + beast::Journal j_; public: explicit @@ -63,6 +64,12 @@ public: return clock_; } + beast::Journal const& + journal() override + { + return j_; + } + FullBelowCache& fullbelow() override {