From 92b2ca70b7d677d63ed5809fd307c36270dac48a Mon Sep 17 00:00:00 2001 From: seelabs Date: Sat, 19 Sep 2015 11:06:12 -0700 Subject: [PATCH] Inject journals: Calls to WriteLog are replaced with injected journals --- src/ripple/app/ledger/AcceptedLedger.cpp | 4 +- src/ripple/app/ledger/AcceptedLedger.h | 2 +- src/ripple/app/ledger/AcceptedLedgerTx.cpp | 13 +- src/ripple/app/ledger/AcceptedLedgerTx.h | 9 +- src/ripple/app/ledger/ConsensusTransSetSF.cpp | 7 +- src/ripple/app/ledger/ConsensusTransSetSF.h | 1 + src/ripple/app/ledger/Ledger.cpp | 61 +++--- src/ripple/app/ledger/Ledger.h | 7 +- src/ripple/app/ledger/LedgerConsensus.h | 3 +- src/ripple/app/ledger/LedgerHistory.cpp | 95 ++++----- src/ripple/app/ledger/LedgerHistory.h | 2 + src/ripple/app/ledger/OrderBookDB.cpp | 11 +- src/ripple/app/ledger/OrderBookDB.h | 2 + src/ripple/app/ledger/impl/DisputedTx.cpp | 16 +- src/ripple/app/ledger/impl/DisputedTx.h | 5 +- src/ripple/app/ledger/impl/InboundLedger.cpp | 6 +- src/ripple/app/ledger/impl/InboundLedgers.cpp | 10 +- src/ripple/app/ledger/impl/LedgerCleaner.cpp | 2 +- .../app/ledger/impl/LedgerConsensusImp.cpp | 186 +++++++++--------- .../app/ledger/impl/LedgerConsensusImp.h | 1 + src/ripple/app/ledger/impl/LedgerMaster.cpp | 96 ++++----- src/ripple/app/main/Application.cpp | 76 +++---- src/ripple/app/main/Application.h | 1 + src/ripple/app/main/Main.cpp | 4 +- src/ripple/app/misc/NetworkOPs.cpp | 16 +- src/ripple/app/misc/UniqueNodeList.cpp | 138 ++++++------- src/ripple/app/misc/Validations.cpp | 22 ++- src/ripple/app/misc/impl/AccountTxPaging.cpp | 2 +- src/ripple/app/paths/PathRequest.cpp | 5 +- src/ripple/app/paths/PathState.cpp | 58 +++--- src/ripple/app/paths/PathState.h | 6 +- src/ripple/app/paths/Pathfinder.cpp | 80 ++++---- src/ripple/app/paths/Pathfinder.h | 1 + src/ripple/app/paths/RippleCalc.cpp | 41 ++-- src/ripple/app/paths/RippleCalc.h | 9 +- src/ripple/app/paths/cursor/AdvanceNode.cpp | 53 ++--- .../app/paths/cursor/DeliverNodeForward.cpp | 31 +-- .../app/paths/cursor/DeliverNodeReverse.cpp | 35 ++-- .../cursor/ForwardLiquidityForAccount.cpp | 31 +-- src/ripple/app/paths/cursor/Liquidity.cpp | 10 +- src/ripple/app/paths/cursor/NextIncrement.cpp | 4 +- src/ripple/app/paths/cursor/PathCursor.h | 7 +- .../app/paths/cursor/ReverseLiquidity.cpp | 4 +- .../cursor/ReverseLiquidityForAccount.cpp | 38 ++-- .../app/paths/cursor/RippleLiquidity.cpp | 16 +- src/ripple/app/tx/Transaction.h | 2 + src/ripple/app/tx/TransactionAcquire.h | 1 + src/ripple/app/tx/impl/BookTip.cpp | 8 +- src/ripple/app/tx/impl/BookTip.h | 4 +- src/ripple/app/tx/impl/CancelOffer.cpp | 2 +- src/ripple/app/tx/impl/CancelTicket.cpp | 5 +- src/ripple/app/tx/impl/CreateOffer.cpp | 45 +++-- src/ripple/app/tx/impl/CreateOffer.h | 2 +- src/ripple/app/tx/impl/CreateTicket.cpp | 6 +- .../app/tx/impl/InboundTransactions.cpp | 2 +- src/ripple/app/tx/impl/OfferStream.cpp | 15 +- src/ripple/app/tx/impl/OfferStream.h | 2 +- src/ripple/app/tx/impl/Payment.cpp | 1 + src/ripple/app/tx/impl/SetSignerList.cpp | 10 +- src/ripple/app/tx/impl/SetTrust.cpp | 16 +- src/ripple/app/tx/impl/SusPay.cpp | 6 +- src/ripple/app/tx/impl/Taker.cpp | 8 +- src/ripple/app/tx/impl/Transaction.cpp | 7 +- src/ripple/app/tx/impl/TransactionAcquire.cpp | 25 +-- src/ripple/app/tx/impl/TransactionMaster.cpp | 2 +- src/ripple/app/tx/impl/Transactor.cpp | 7 +- src/ripple/core/Config.h | 4 +- src/ripple/core/DatabaseCon.h | 2 +- src/ripple/core/JobQueue.h | 4 +- src/ripple/core/JobTypeData.h | 8 +- src/ripple/core/LoadMonitor.h | 5 +- src/ripple/core/SociDB.h | 2 +- src/ripple/core/impl/Config.cpp | 60 +++--- src/ripple/core/impl/DatabaseCon.cpp | 4 +- src/ripple/core/impl/JobQueue.cpp | 10 +- src/ripple/core/impl/LoadMonitor.cpp | 6 +- src/ripple/core/impl/SociDB.cpp | 15 +- src/ripple/ledger/ApplyView.h | 3 + src/ripple/ledger/ReadView.h | 8 +- src/ripple/ledger/TxMeta.h | 17 +- src/ripple/ledger/View.h | 50 +++-- src/ripple/ledger/impl/ApplyStateTable.cpp | 2 +- src/ripple/ledger/impl/TxMeta.cpp | 23 ++- src/ripple/ledger/impl/View.cpp | 185 +++++++++-------- .../ledger/tests/PaymentSandbox_test.cpp | 66 ++++--- src/ripple/net/HTTPClient.h | 9 +- src/ripple/net/RPCCall.h | 4 +- src/ripple/net/RPCSub.h | 3 +- src/ripple/net/impl/HTTPClient.cpp | 68 ++++--- src/ripple/net/impl/HTTPRequest.cpp | 2 - src/ripple/net/impl/RPCCall.cpp | 43 ++-- src/ripple/net/impl/RPCSub.cpp | 28 ++- src/ripple/overlay/PeerSet.h | 4 +- src/ripple/overlay/impl/Manifest.cpp | 10 +- src/ripple/overlay/impl/Manifest.h | 10 +- src/ripple/overlay/impl/OverlayImpl.cpp | 6 +- src/ripple/overlay/impl/PeerImp.cpp | 4 +- src/ripple/overlay/impl/PeerImp.h | 4 +- src/ripple/overlay/impl/PeerSet.cpp | 11 +- src/ripple/protocol/tests/STAmount.test.cpp | 34 ++-- src/ripple/protocol/tests/STObject.test.cpp | 4 +- src/ripple/rpc/Context.h | 3 + src/ripple/rpc/handlers/BookOffers.cpp | 6 +- src/ripple/rpc/handlers/Internal.cpp | 4 +- src/ripple/rpc/handlers/LedgerRequest.cpp | 2 +- src/ripple/rpc/handlers/RipplePathFind.cpp | 29 +-- src/ripple/rpc/handlers/Subscribe.cpp | 24 +-- src/ripple/rpc/handlers/Tx.cpp | 3 +- src/ripple/rpc/handlers/Unsubscribe.cpp | 10 +- src/ripple/rpc/handlers/ValidationCreate.cpp | 2 +- src/ripple/rpc/impl/LookupLedger.cpp | 2 +- src/ripple/rpc/impl/RPCHandler.cpp | 14 +- src/ripple/rpc/impl/TransactionSign.cpp | 32 +-- src/ripple/server/impl/JSONRPCUtil.cpp | 8 +- src/ripple/server/impl/JSONRPCUtil.h | 3 +- src/ripple/server/impl/ServerHandlerImp.cpp | 33 ++-- src/ripple/shamap/Family.h | 1 + src/ripple/shamap/SHAMapTreeNode.h | 5 +- src/ripple/shamap/impl/SHAMap.cpp | 8 +- src/ripple/shamap/impl/SHAMapSync.cpp | 9 +- src/ripple/shamap/impl/SHAMapTreeNode.cpp | 8 +- src/ripple/shamap/tests/SHAMap.test.cpp | 1 - src/ripple/shamap/tests/SHAMapSync.test.cpp | 1 - src/ripple/shamap/tests/common.h | 1 - src/ripple/websocket/AutoSocket.h | 27 ++- src/ripple/websocket/Connection.h | 10 +- src/ripple/websocket/Handler.h | 25 ++- src/ripple/websocket/MakeServer.cpp | 2 +- src/ripple/websocket/Server.h | 12 +- src/ripple/websocket/WebSocket02.cpp | 4 +- src/ripple/websocket/WebSocket04.cpp | 2 +- 131 files changed, 1336 insertions(+), 1076 deletions(-) diff --git a/src/ripple/app/ledger/AcceptedLedger.cpp b/src/ripple/app/ledger/AcceptedLedger.cpp index bb79a14323..7ceaffb123 100644 --- a/src/ripple/app/ledger/AcceptedLedger.cpp +++ b/src/ripple/app/ledger/AcceptedLedger.cpp @@ -26,13 +26,13 @@ namespace ripple { AcceptedLedger::AcceptedLedger ( std::shared_ptr const& ledger, - AccountIDCache const& accountCache) + AccountIDCache const& accountCache, Logs& logs) : mLedger (ledger) { for (auto const& item : ledger->txs) { insert (std::make_shared( - ledger, item.first, item.second, accountCache)); + ledger, item.first, item.second, accountCache, logs)); } } diff --git a/src/ripple/app/ledger/AcceptedLedger.h b/src/ripple/app/ledger/AcceptedLedger.h index cd31538dc8..db2dee3bd3 100644 --- a/src/ripple/app/ledger/AcceptedLedger.h +++ b/src/ripple/app/ledger/AcceptedLedger.h @@ -70,7 +70,7 @@ public: AcceptedLedger ( std::shared_ptr const& ledger, - AccountIDCache const& accountCache); + AccountIDCache const& accountCache, Logs& logs); private: void insert (AcceptedLedgerTx::ref); diff --git a/src/ripple/app/ledger/AcceptedLedgerTx.cpp b/src/ripple/app/ledger/AcceptedLedgerTx.cpp index 03ab1af4ca..61dfc30632 100644 --- a/src/ripple/app/ledger/AcceptedLedgerTx.cpp +++ b/src/ripple/app/ledger/AcceptedLedgerTx.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -30,13 +31,15 @@ AcceptedLedgerTx::AcceptedLedgerTx ( std::shared_ptr const& ledger, std::shared_ptr const& txn, std::shared_ptr const& met, - AccountIDCache const& accountCache) + AccountIDCache const& accountCache, + Logs& logs) : mLedger (ledger) , mTxn (txn) , mMeta (std::make_shared ( - txn->getTransactionID(), ledger->seq(), *met)) + txn->getTransactionID(), ledger->seq(), *met, logs.journal ("View"))) , mAffected (mMeta->getAffectedAccounts ()) , accountCache_ (accountCache) + , logs_ (logs) { assert (! ledger->info().open); @@ -53,12 +56,14 @@ AcceptedLedgerTx::AcceptedLedgerTx ( std::shared_ptr const& ledger, STTx::ref txn, TER result, - AccountIDCache const& accountCache) + AccountIDCache const& accountCache, + Logs& logs) : mLedger (ledger) , mTxn (txn) , mResult (result) , mAffected (txn->getMentionedAccounts ()) , accountCache_ (accountCache) + , logs_ (logs) { assert (ledger->info().open); buildJson (); @@ -99,7 +104,7 @@ void AcceptedLedgerTx::buildJson () if (account != amount.issue ().account) { auto const ownerFunds = accountFunds(*mLedger, - account, amount, fhIGNORE_FREEZE); + account, amount, fhIGNORE_FREEZE, logs_.journal ("View")); mJson[jss::transaction][jss::owner_funds] = ownerFunds.getText (); } } diff --git a/src/ripple/app/ledger/AcceptedLedgerTx.h b/src/ripple/app/ledger/AcceptedLedgerTx.h index c8504e7494..e4552b791d 100644 --- a/src/ripple/app/ledger/AcceptedLedgerTx.h +++ b/src/ripple/app/ledger/AcceptedLedgerTx.h @@ -26,6 +26,8 @@ namespace ripple { +class Logs; + /** A transaction that is in a closed ledger. @@ -56,12 +58,14 @@ public: std::shared_ptr const& ledger, std::shared_ptr const&, std::shared_ptr const&, - AccountIDCache const&); + AccountIDCache const&, + Logs&); AcceptedLedgerTx ( std::shared_ptr const&, STTx::ref, TER, - AccountIDCache const&); + AccountIDCache const&, + Logs&); std::shared_ptr const& getTxn () const { @@ -118,6 +122,7 @@ private: Blob mRawMeta; Json::Value mJson; AccountIDCache const& accountCache_; + Logs& logs_; void buildJson (); }; diff --git a/src/ripple/app/ledger/ConsensusTransSetSF.cpp b/src/ripple/app/ledger/ConsensusTransSetSF.cpp index eca0224445..87c8f9fd66 100644 --- a/src/ripple/app/ledger/ConsensusTransSetSF.cpp +++ b/src/ripple/app/ledger/ConsensusTransSetSF.cpp @@ -33,6 +33,7 @@ namespace ripple { ConsensusTransSetSF::ConsensusTransSetSF (Application& app, NodeCache& nodeCache) : app_ (app) , m_nodeCache (nodeCache) + , j_ (app.journal ("TransactionAcquire")) { } @@ -48,7 +49,7 @@ void ConsensusTransSetSF::gotNode ( if ((type == SHAMapTreeNode::tnTRANSACTION_NM) && (nodeData.size () > 16)) { // this is a transaction, and we didn't have it - WriteLog (lsDEBUG, TransactionAcquire) + JLOG (j_.debug) << "Node on our acquiring TX set is TXN we may not have"; try @@ -67,7 +68,7 @@ void ConsensusTransSetSF::gotNode ( } catch (...) { - WriteLog (lsWARNING, TransactionAcquire) + JLOG (j_.warning) << "Fetched invalid transaction in proposed set"; } } @@ -84,7 +85,7 @@ bool ConsensusTransSetSF::haveNode ( if (txn) { // this is a transaction, and we have it - WriteLog (lsTRACE, TransactionAcquire) + JLOG (j_.trace) << "Node in our acquiring TX set is TXN we have"; Serializer s; s.add32 (HashPrefix::transactionID); diff --git a/src/ripple/app/ledger/ConsensusTransSetSF.h b/src/ripple/app/ledger/ConsensusTransSetSF.h index 748a9e40dd..fb9a209aa1 100644 --- a/src/ripple/app/ledger/ConsensusTransSetSF.h +++ b/src/ripple/app/ledger/ConsensusTransSetSF.h @@ -52,6 +52,7 @@ public: private: Application& app_; NodeCache& m_nodeCache; + beast::Journal j_; }; } // ripple diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 420f5fbc98..17902b01ae 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -205,7 +205,8 @@ Ledger::Ledger (uint256 const& parentHash, std::uint32_t ledgerSeq, bool& loaded, Config const& config, - Family& family) + Family& family, + beast::Journal j) : mImmutable (true) , txMap_ (std::make_shared ( SHAMapType::TRANSACTION, transHash, family)) @@ -227,14 +228,14 @@ Ledger::Ledger (uint256 const& parentHash, !txMap_->fetchRoot (info_.txHash, nullptr)) { loaded = false; - WriteLog (lsWARNING, Ledger) << "Don't have TX root for ledger"; + JLOG (j.warning) << "Don't have TX root for ledger"; } if (info_.accountHash.isNonZero () && !stateMap_->fetchRoot (info_.accountHash, nullptr)) { loaded = false; - WriteLog (lsWARNING, Ledger) << "Don't have AS root for ledger"; + JLOG (j.warning) << "Don't have AS root for ledger"; } txMap_->setImmutable (); @@ -789,7 +790,7 @@ void Ledger::visitStateItems (std::function callback) const } } -bool Ledger::walkLedger () const +bool Ledger::walkLedger (beast::Journal j) const { std::vector missingNodes1; std::vector missingNodes2; @@ -807,9 +808,9 @@ bool Ledger::walkLedger () const if (ShouldLog (lsINFO, Ledger) && !missingNodes1.empty ()) { - WriteLog (lsINFO, Ledger) + JLOG (j.info) << missingNodes1.size () << " missing account node(s)"; - WriteLog (lsINFO, Ledger) + JLOG (j.info) << "First: " << missingNodes1[0]; } @@ -826,16 +827,16 @@ bool Ledger::walkLedger () const if (ShouldLog (lsINFO, Ledger) && !missingNodes2.empty ()) { - WriteLog (lsINFO, Ledger) + JLOG (j.info) << missingNodes2.size () << " missing transaction node(s)"; - WriteLog (lsINFO, Ledger) + JLOG (j.info) << "First: " << missingNodes2[0]; } return missingNodes1.empty () && missingNodes2.empty (); } -bool Ledger::assertSane () +bool Ledger::assertSane (beast::Journal ledgerJ) { if (info_.hash.isNonZero () && info_.accountHash.isNonZero () && @@ -852,7 +853,7 @@ bool Ledger::assertSane () j [jss::accountTreeHash] = to_string (info_.accountHash); j [jss::transTreeHash] = to_string (info_.txHash); - WriteLog (lsFATAL, Ledger) << "ledger is not sane" << j; + JLOG (ledgerJ.fatal) << "ledger is not sane" << j; assert (false); @@ -930,7 +931,8 @@ static bool saveValidatedLedger ( Application& app, std::shared_ptr const& ledger, bool current) { // TODO(tom): Fix this hard-coded SQL! - WriteLog (lsTRACE, Ledger) + auto j = app.journal ("Ledger"); + JLOG (j.trace) << "saveValidatedLedger " << (current ? "" : "fromAcquire ") << ledger->info().seq; static boost::format deleteLedger ( @@ -956,16 +958,16 @@ static bool saveValidatedLedger ( if (! ledger->info().accountHash.isNonZero ()) { - WriteLog (lsFATAL, Ledger) << "AH is zero: " + JLOG (j.fatal) << "AH is zero: " << getJson (*ledger); assert (false); } if (ledger->info().accountHash != ledger->stateMap().getHash ()) { - WriteLog (lsFATAL, Ledger) << "sAL: " << ledger->info().accountHash + JLOG (j.fatal) << "sAL: " << ledger->info().accountHash << " != " << ledger->stateMap().getHash (); - WriteLog (lsFATAL, Ledger) << "saveAcceptedLedger: seq=" + JLOG (j.fatal) << "saveAcceptedLedger: seq=" << seq << ", current=" << current; assert (false); } @@ -988,13 +990,13 @@ static bool saveValidatedLedger ( aLedger = app.getAcceptedLedgerCache().fetch (ledger->info().hash); if (! aLedger) { - aLedger = std::make_shared(ledger, app.accountIDCache()); + aLedger = std::make_shared(ledger, app.accountIDCache(), app.logs()); app.getAcceptedLedgerCache().canonicalize(ledger->info().hash, aLedger); } } catch (...) { - WriteLog (lsWARNING, Ledger) << "An accepted ledger was missing nodes"; + JLOG (j.warning) << "An accepted ledger was missing nodes"; app.getLedgerMaster().failedSave(seq, ledger->info().hash); // Clients can now trust the database for information about this // ledger sequence. @@ -1065,12 +1067,12 @@ static bool saveValidatedLedger ( sql += ";"; if (ShouldLog (lsTRACE, Ledger)) { - WriteLog (lsTRACE, Ledger) << "ActTx: " << sql; + JLOG (j.trace) << "ActTx: " << sql; } *db << sql; } else - WriteLog (lsWARNING, Ledger) + JLOG (j.warning) << "Transaction in ledger " << seq << " affects no accounts"; @@ -1110,7 +1112,7 @@ bool pendSaveValidated (Application& app, { if (! app.getHashRouter ().setFlags (ledger->info().hash, SF_SAVED)) { - WriteLog (lsDEBUG, Ledger) << "Double pend save for " + JLOG (app.journal ("Ledger").debug) << "Double pend save for " << ledger->info().seq; return true; } @@ -1119,7 +1121,7 @@ bool pendSaveValidated (Application& app, if (! app.pendingSaves().insert (ledger->info().seq)) { - WriteLog (lsDEBUG, Ledger) + JLOG (app.journal ("Ledger").debug) << "Pend save with seq in pending saves " << ledger->info().seq; return true; @@ -1253,7 +1255,7 @@ loadLedgerHelper(std::string const& sqlSuffix, Application& app) if (!db->got_data ()) { - WriteLog (lsDEBUG, Ledger) << "Ledger not found: " << sqlSuffix; + JLOG (app.journal("Ledger").debug) << "Ledger not found: " << sqlSuffix; return std::make_tuple (Ledger::pointer (), ledgerSeq, ledgerHash); } @@ -1282,7 +1284,8 @@ loadLedgerHelper(std::string const& sqlSuffix, Application& app) ledgerSeq, loaded, app.config(), - app.family()); + app.family(), + app.journal("Ledger")); if (!loaded) return std::make_tuple (Ledger::pointer (), ledgerSeq, ledgerHash); @@ -1290,7 +1293,8 @@ loadLedgerHelper(std::string const& sqlSuffix, Application& app) return std::make_tuple (ledger, ledgerSeq, ledgerHash); } -void finishLoadByIndexOrHash(Ledger::pointer& ledger, Config const& config) +static +void finishLoadByIndexOrHash(Ledger::pointer& ledger, Config const& config, beast::Journal j) { if (!ledger) return; @@ -1298,7 +1302,7 @@ void finishLoadByIndexOrHash(Ledger::pointer& ledger, Config const& config) ledger->setClosed (); ledger->setImmutable (config); - WriteLog (lsTRACE, Ledger) + JLOG (j.trace) << "Loaded ledger: " << to_string (ledger->getHash ()); ledger->setFull (); @@ -1315,7 +1319,7 @@ loadByIndex (std::uint32_t ledgerIndex, Application& app) loadLedgerHelper (s.str (), app); } - finishLoadByIndexOrHash (ledger, app.config()); + finishLoadByIndexOrHash (ledger, app.config(), app.journal ("Ledger")); return ledger; } @@ -1330,7 +1334,7 @@ loadByHash (uint256 const& ledgerHash, Application& app) loadLedgerHelper (s.str (), app); } - finishLoadByIndexOrHash (ledger, app.config()); + finishLoadByIndexOrHash (ledger, app.config(), app.journal ("Ledger")); assert (!ledger || ledger->getHash () == ledgerHash); @@ -1384,7 +1388,8 @@ getHashesByIndex(std::uint32_t ledgerIndex, if (!lhO || !phO) { - WriteLog (lsTRACE, Ledger) << "Don't have ledger " << ledgerIndex; + JLOG (app.journal ("Ledger").trace) + << "Don't have ledger " << ledgerIndex; return false; } @@ -1430,7 +1435,7 @@ getHashesByIndex (std::uint32_t minSeq, std::uint32_t maxSeq, hashes.second.zero (); if (!ph) { - WriteLog (lsWARNING, Ledger) + JLOG (app.journal ("Ledger").warning) << "Null prev hash for ledger seq: " << ls; } } diff --git a/src/ripple/app/ledger/Ledger.h b/src/ripple/app/ledger/Ledger.h index fa974983d8..ba1ad03e7e 100644 --- a/src/ripple/app/ledger/Ledger.h +++ b/src/ripple/app/ledger/Ledger.h @@ -107,7 +107,8 @@ public: std::uint64_t totDrops, std::uint32_t closeTime, std::uint32_t parentCloseTime, int closeFlags, int closeResolution, std::uint32_t ledgerSeq, bool & loaded, Config const& config, - Family& family); + Family& family, + beast::Journal j); // Create a new ledger that's a snapshot of this one Ledger (Ledger const& target, bool isMutable); @@ -330,9 +331,9 @@ public: std::vector getNeededAccountStateHashes ( int max, SHAMapSyncFilter* filter) const; - bool walkLedger () const; + bool walkLedger (beast::Journal j) const; - bool assertSane (); + bool assertSane (beast::Journal ledgerJ); private: class sles_iter_impl; diff --git a/src/ripple/app/ledger/LedgerConsensus.h b/src/ripple/app/ledger/LedgerConsensus.h index 0f6f0205c4..e26d5835dd 100644 --- a/src/ripple/app/ledger/LedgerConsensus.h +++ b/src/ripple/app/ledger/LedgerConsensus.h @@ -99,7 +99,8 @@ int applyTransaction ( OpenView& view, std::shared_ptr const& txn, bool retryAssured, - ApplyFlags flags); + ApplyFlags flags, + beast::Journal j); } // ripple diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/ripple/app/ledger/LedgerHistory.cpp index 64edcc4a28..8f3bd98e56 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/ripple/app/ledger/LedgerHistory.cpp @@ -45,9 +45,10 @@ LedgerHistory::LedgerHistory ( , collector_ (collector) , mismatch_counter_ (collector->make_counter ("ledger.history", "mismatch")) , m_ledgers_by_hash ("LedgerCache", CACHED_LEDGER_NUM, CACHED_LEDGER_AGE, - stopwatch(), app_.logs().journal("TaggedCache")) + stopwatch(), app_.journal("TaggedCache")) , m_consensus_validated ("ConsensusValidated", 64, 300, - stopwatch(), app_.logs().journal("TaggedCache")) + stopwatch(), app_.journal("TaggedCache")) + , j_ (app.journal ("LedgerHistory")) { } @@ -135,19 +136,20 @@ Ledger::pointer LedgerHistory::getLedgerByHash (LedgerHash const& hash) static void -log_one(Ledger::pointer ledger, uint256 const& tx, char const* msg) +log_one(Ledger::pointer ledger, uint256 const& tx, char const* msg, + beast::Journal& j) { auto metaData = ledger->txRead(tx).second; if (metaData != nullptr) { - WriteLog (lsDEBUG, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.debug) << "MISMATCH on TX " << tx << ": " << msg << " is missing this transaction:\n" << metaData->getJson (0); } else { - WriteLog (lsDEBUG, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.debug) << "MISMATCH on TX " << tx << ": " << msg << " is missing this transaction."; } } @@ -155,15 +157,16 @@ log_one(Ledger::pointer ledger, uint256 const& tx, char const* msg) static void log_metadata_difference( - Ledger::pointer builtLedger, Ledger::pointer validLedger, uint256 const& tx) + Ledger::pointer builtLedger, Ledger::pointer validLedger, uint256 const& tx, + beast::Journal j) { - auto getMeta = [](Ledger const& ledger, + auto getMeta = [j](Ledger const& ledger, uint256 const& txID) -> std::shared_ptr { auto meta = ledger.txRead(txID).second; if (!meta) return {}; - return std::make_shared (txID, ledger.seq(), *meta); + return std::make_shared (txID, ledger.seq(), *meta, j); }; auto validMetaData = getMeta (*validLedger, tx); @@ -185,7 +188,7 @@ log_metadata_difference( if (!result_diff && !index_diff && !nodes_diff) { - WriteLog (lsERROR, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.error) << "MISMATCH on TX " << tx << ": No apparent mismatches detected!"; return; } @@ -194,31 +197,31 @@ log_metadata_difference( { if (result_diff && index_diff) { - WriteLog (lsDEBUG, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.debug) << "MISMATCH on TX " << tx << ": Different result and index!"; - WriteLog (lsDEBUG, LedgerMaster) << " Built:" << + JLOG (j.debug) << " Built:" << " Result: " << builtMetaData->getResult () << " Index: " << builtMetaData->getIndex (); - WriteLog (lsDEBUG, LedgerMaster) << " Valid:" << + JLOG (j.debug) << " Valid:" << " Result: " << validMetaData->getResult () << " Index: " << validMetaData->getIndex (); } else if (result_diff) { - WriteLog (lsDEBUG, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.debug) << "MISMATCH on TX " << tx << ": Different result!"; - WriteLog (lsDEBUG, LedgerMaster) << " Built:" << + JLOG (j.debug) << " Built:" << " Result: " << builtMetaData->getResult (); - WriteLog (lsDEBUG, LedgerMaster) << " Valid:" << + JLOG (j.debug) << " Valid:" << " Result: " << validMetaData->getResult (); } else if (index_diff) { - WriteLog (lsDEBUG, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.debug) << "MISMATCH on TX " << tx << ": Different index!"; - WriteLog (lsDEBUG, LedgerMaster) << " Built:" << + JLOG (j.debug) << " Built:" << " Index: " << builtMetaData->getIndex (); - WriteLog (lsDEBUG, LedgerMaster) << " Valid:" << + JLOG (j.debug) << " Valid:" << " Index: " << validMetaData->getIndex (); } } @@ -226,55 +229,55 @@ log_metadata_difference( { if (result_diff && index_diff) { - WriteLog (lsDEBUG, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.debug) << "MISMATCH on TX " << tx << ": Different result, index and nodes!"; - WriteLog (lsDEBUG, LedgerMaster) << " Built:\n" << + JLOG (j.debug) << " Built:\n" << builtMetaData->getJson (0); - WriteLog (lsDEBUG, LedgerMaster) << " Valid:\n" << + JLOG (j.debug) << " Valid:\n" << validMetaData->getJson (0); } else if (result_diff) { - WriteLog (lsDEBUG, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.debug) << "MISMATCH on TX " << tx << ": Different result and nodes!"; - WriteLog (lsDEBUG, LedgerMaster) << " Built:" << + JLOG (j.debug) << " Built:" << " Result: " << builtMetaData->getResult () << " Nodes:\n" << builtNodes.getJson (0); - WriteLog (lsDEBUG, LedgerMaster) << " Valid:" << + JLOG (j.debug) << " Valid:" << " Result: " << validMetaData->getResult () << " Nodes:\n" << validNodes.getJson (0); } else if (index_diff) { - WriteLog (lsDEBUG, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.debug) << "MISMATCH on TX " << tx << ": Different index and nodes!"; - WriteLog (lsDEBUG, LedgerMaster) << " Built:" << + JLOG (j.debug) << " Built:" << " Index: " << builtMetaData->getIndex () << " Nodes:\n" << builtNodes.getJson (0); - WriteLog (lsDEBUG, LedgerMaster) << " Valid:" << + JLOG (j.debug) << " Valid:" << " Index: " << validMetaData->getIndex () << " Nodes:\n" << validNodes.getJson (0); } else // nodes_diff { - WriteLog (lsDEBUG, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.debug) << "MISMATCH on TX " << tx << ": Different nodes!"; - WriteLog (lsDEBUG, LedgerMaster) << " Built:" << + JLOG (j.debug) << " Built:" << " Nodes:\n" << builtNodes.getJson (0); - WriteLog (lsDEBUG, LedgerMaster) << " Valid:" << + JLOG (j.debug) << " Valid:" << " Nodes:\n" << validNodes.getJson (0); } } } else if (validMetaData != nullptr) { - WriteLog (lsERROR, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.error) << "MISMATCH on TX " << tx << ": Metadata Difference (built has none)\n" << validMetaData->getJson (0); } else // builtMetaData != nullptr { - WriteLog (lsERROR, LedgerMaster) << "MISMATCH on TX " << tx << + JLOG (j.error) << "MISMATCH on TX " << tx << ": Metadata Difference (valid has none)\n" << builtMetaData->getJson (0); } @@ -308,7 +311,7 @@ void LedgerHistory::handleMismatch ( if (!builtLedger || !validLedger) { - WriteLog (lsERROR, LedgerMaster) << "MISMATCH cannot be analyzed:" << + JLOG (j_.error) << "MISMATCH cannot be analyzed:" << " builtLedger: " << to_string (built) << " -> " << builtLedger << " validLedger: " << to_string (valid) << " -> " << validLedger; return; @@ -322,14 +325,14 @@ void LedgerHistory::handleMismatch ( if (builtLedger->info().parentHash != validLedger->info().parentHash) { // Disagreement over prior ledger indicates sync issue - WriteLog (lsERROR, LedgerMaster) << "MISMATCH on prior ledger"; + JLOG (j_.error) << "MISMATCH on prior ledger"; return; } if (builtLedger->info().closeTime != validLedger->info().closeTime) { // Disagreement over close time indicates Byzantine failure - WriteLog (lsERROR, LedgerMaster) << "MISMATCH on close time"; + JLOG (j_.error) << "MISMATCH on close time"; return; } @@ -337,16 +340,16 @@ void LedgerHistory::handleMismatch ( auto const builtTx = leaves(builtLedger->txMap()); auto const validTx = leaves(validLedger->txMap()); if (builtTx == validTx) - WriteLog (lsERROR, LedgerMaster) << + JLOG (j_.error) << "MISMATCH with same " << builtTx.size() << " transactions"; else - WriteLog (lsERROR, LedgerMaster) << "MISMATCH with " << + JLOG (j_.error) << "MISMATCH with " << builtTx.size() << " built and " << validTx.size() << " valid transactions."; - WriteLog(lsERROR, LedgerMaster) << "built\n" << + JLOG (j_.error) << "built\n" << getJson(*builtLedger); - WriteLog(lsERROR, LedgerMaster) << "valid\n" << + JLOG (j_.error) << "valid\n" << getJson(*validLedger); // Log all differences between built and valid ledgers @@ -356,12 +359,12 @@ void LedgerHistory::handleMismatch ( { if ((*b)->key() < (*v)->key()) { - log_one (builtLedger, (*b)->key(), "valid"); + log_one (builtLedger, (*b)->key(), "valid", j_); ++b; } else if ((*b)->key() > (*v)->key()) { - log_one(validLedger, (*v)->key(), "built"); + log_one(validLedger, (*v)->key(), "built", j_); ++v; } else @@ -369,16 +372,16 @@ void LedgerHistory::handleMismatch ( if ((*b)->peekData() != (*v)->peekData()) { // Same transaction with different metadata - log_metadata_difference(builtLedger, validLedger, (*b)->key()); + log_metadata_difference(builtLedger, validLedger, (*b)->key(), j_); } ++b; ++v; } } for (; b != builtTx.end(); ++b) - log_one (builtLedger, (*b)->key(), "valid"); + log_one (builtLedger, (*b)->key(), "valid", j_); for (; v != validTx.end(); ++v) - log_one (validLedger, (*v)->key(), "built"); + log_one (validLedger, (*v)->key(), "built", j_); } void LedgerHistory::builtLedger (Ledger::ref ledger) @@ -396,7 +399,7 @@ void LedgerHistory::builtLedger (Ledger::ref ledger) { if (entry->second.isNonZero() && (entry->second != hash)) { - WriteLog (lsERROR, LedgerMaster) << "MISMATCH: seq=" << index + JLOG (j_.error) << "MISMATCH: seq=" << index << " validated:" << entry->second << " then:" << hash; handleMismatch (hash, entry->first); @@ -420,7 +423,7 @@ void LedgerHistory::validatedLedger (Ledger::ref ledger) { if (entry->first.isNonZero() && (entry->first != hash)) { - WriteLog (lsERROR, LedgerMaster) << "MISMATCH: seq=" << index + JLOG (j_.error) << "MISMATCH: seq=" << index << " built:" << entry->first << " then:" << hash; handleMismatch (entry->first, hash); diff --git a/src/ripple/app/ledger/LedgerHistory.h b/src/ripple/app/ledger/LedgerHistory.h index 19642f319e..f7a37a7d35 100644 --- a/src/ripple/app/ledger/LedgerHistory.h +++ b/src/ripple/app/ledger/LedgerHistory.h @@ -126,6 +126,8 @@ private: // Maps ledger indexes to the corresponding hash. std::map mLedgersByIndex; // validated ledgers + + beast::Journal j_; }; } // ripple diff --git a/src/ripple/app/ledger/OrderBookDB.cpp b/src/ripple/app/ledger/OrderBookDB.cpp index 513ecd266e..4f843ddfbe 100644 --- a/src/ripple/app/ledger/OrderBookDB.cpp +++ b/src/ripple/app/ledger/OrderBookDB.cpp @@ -32,6 +32,7 @@ OrderBookDB::OrderBookDB (Application& app, Stoppable& parent) : Stoppable ("OrderBookDB", parent) , app_ (app) , mSeq (0) + , j_ (app.journal ("OrderBookDB")) { } @@ -59,7 +60,7 @@ void OrderBookDB::setup( return; } - WriteLog (lsDEBUG, OrderBookDB) + JLOG (j_.debug) << "Advancing from " << mSeq << " to " << seq; mSeq = seq; @@ -81,7 +82,7 @@ void OrderBookDB::update( OrderBookDB::IssueToOrderBook sourceMap; hash_set< Issue > XRPBooks; - WriteLog (lsDEBUG, OrderBookDB) << "OrderBookDB::update>"; + JLOG (j_.debug) << "OrderBookDB::update>"; // walk through the entire ledger looking for orderbook entries int books = 0; @@ -119,14 +120,14 @@ void OrderBookDB::update( } catch (const SHAMapMissingNode&) { - WriteLog (lsINFO, OrderBookDB) + JLOG (j_.info) << "OrderBookDB::update encountered a missing node"; ScopedLockType sl (mLock); mSeq = 0; return; } - WriteLog (lsDEBUG, OrderBookDB) + JLOG (j_.debug) << "OrderBookDB::update< " << books << " books found"; { ScopedLockType sl (mLock); @@ -271,7 +272,7 @@ void OrderBookDB::processTxn ( } catch (...) { - WriteLog (lsINFO, OrderBookDB) + JLOG (j_.info) << "Fields not found in OrderBookDB::processTxn"; } } diff --git a/src/ripple/app/ledger/OrderBookDB.h b/src/ripple/app/ledger/OrderBookDB.h index 6689685ac9..dee03f1d5d 100644 --- a/src/ripple/app/ledger/OrderBookDB.h +++ b/src/ripple/app/ledger/OrderBookDB.h @@ -82,6 +82,8 @@ private: BookToListenersMap mListeners; std::uint32_t mSeq; + + beast::Journal j_; }; } // ripple diff --git a/src/ripple/app/ledger/impl/DisputedTx.cpp b/src/ripple/app/ledger/impl/DisputedTx.cpp index e53f2777fa..9afce73371 100644 --- a/src/ripple/app/ledger/impl/DisputedTx.cpp +++ b/src/ripple/app/ledger/impl/DisputedTx.cpp @@ -35,13 +35,13 @@ void DisputedTx::setVote (NodeID const& peer, bool votesYes) { if (votesYes) { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Peer " << peer << " votes YES on " << mTransactionID; ++mYays; } else { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Peer " << peer << " votes NO on " << mTransactionID; ++mNays; } @@ -49,7 +49,7 @@ void DisputedTx::setVote (NodeID const& peer, bool votesYes) // changes vote to yes else if (votesYes && !res.first->second) { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Peer " << peer << " now votes YES on " << mTransactionID; --mNays; ++mYays; @@ -58,7 +58,7 @@ void DisputedTx::setVote (NodeID const& peer, bool votesYes) // changes vote to no else if (!votesYes && res.first->second) { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Peer " << peer << " now votes NO on " << mTransactionID; ++mNays; --mYays; @@ -124,18 +124,18 @@ bool DisputedTx::updateVote (int percentTime, bool proposing) if (newPosition == mOurVote) { - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "No change (" << (mOurVote ? "YES" : "NO") << ") : weight " << weight << ", percent " << percentTime; - WriteLog (lsDEBUG, LedgerConsensus) << getJson (); + JLOG (j_.debug) << getJson (); return false; } mOurVote = newPosition; - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "We now vote " << (mOurVote ? "YES" : "NO") << " on " << mTransactionID; - WriteLog (lsDEBUG, LedgerConsensus) << getJson (); + JLOG (j_.debug) << getJson (); return true; } diff --git a/src/ripple/app/ledger/impl/DisputedTx.h b/src/ripple/app/ledger/impl/DisputedTx.h index 36f7858f5f..fb8e1ccf54 100644 --- a/src/ripple/app/ledger/impl/DisputedTx.h +++ b/src/ripple/app/ledger/impl/DisputedTx.h @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace ripple { @@ -40,12 +41,13 @@ class DisputedTx public: // VFALCO `Blob` is a poor choice of parameter DisputedTx (uint256 const& txID, - Blob const& tx, bool ourVote) + Blob const& tx, bool ourVote, beast::Journal j) : mTransactionID (txID) , mYays (0) , mNays (0) , mOurVote (ourVote) , transaction (tx.data(), tx.size()) + , j_ (j) { } @@ -88,6 +90,7 @@ private: Serializer transaction; hash_map mVotes; + beast::Journal j_; }; } // ripple diff --git a/src/ripple/app/ledger/impl/InboundLedger.cpp b/src/ripple/app/ledger/impl/InboundLedger.cpp index 1fbcdb3248..c010c3ea6e 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, - app.logs().journal("InboundLedger")) + app.journal("InboundLedger")) , mHaveHeader (false) , mHaveState (false) , mHaveTransactions (false) @@ -72,7 +72,7 @@ InboundLedger::InboundLedger ( , mReceiveDispatched (false) { - if (m_journal.trace) m_journal.trace << + JLOG (m_journal.trace) << "Acquiring ledger " << mHash; } @@ -295,7 +295,7 @@ void InboundLedger::onTimer (bool wasProgress, ScopedLockType&) mByHash = true; std::size_t pc = getPeerCount (); - WriteLog (lsDEBUG, InboundLedger) << + JLOG (m_journal.debug) << "No progress(" << pc << ") for ledger " << mHash; diff --git a/src/ripple/app/ledger/impl/InboundLedgers.cpp b/src/ripple/app/ledger/impl/InboundLedgers.cpp index 3831fc3916..0c352abbad 100644 --- a/src/ripple/app/ledger/impl/InboundLedgers.cpp +++ b/src/ripple/app/ledger/impl/InboundLedgers.cpp @@ -41,6 +41,7 @@ private: std::mutex fetchRateMutex_; // measures ledgers per second, constants are important DecayWindow<30, clock_type> fetchRate_; + beast::Journal j_; public: using u256_acq_pair = std::pair; @@ -52,6 +53,7 @@ public: : Stoppable ("InboundLedgers", parent) , app_ (app) , fetchRate_(clock.now()) + , j_ (app.journal ("InboundLedger")) , m_clock (clock) , mRecentFailures (clock) , mCounter(collector->make_counter("ledger_fetches")) @@ -151,7 +153,7 @@ public: { protocol::TMLedgerData& packet = *packet_ptr; - WriteLog (lsTRACE, InboundLedger) + JLOG (j_.trace) << "Got data (" << packet.nodes ().size () << ") for acquiring ledger: " << hash; @@ -159,7 +161,7 @@ public: if (!ledger) { - WriteLog (lsTRACE, InboundLedger) + JLOG (j_.trace) << "Got data for ledger we're no longer acquiring"; // If it's state node data, stash it because it still might be @@ -255,7 +257,7 @@ public: auto newNode = SHAMapAbstractNode::make( Blob (node.nodedata().begin(), node.nodedata().end()), - 0, snfWIRE, uZero, false); + 0, snfWIRE, uZero, false, app_.journal ("SHAMapNodeID")); if (!newNode) return; @@ -395,7 +397,7 @@ public: } - WriteLog (lsDEBUG, InboundLedger) << + JLOG (j_.debug) << "Swept " << stuffToSweep.size () << " out of " << total << " inbound ledgers."; } diff --git a/src/ripple/app/ledger/impl/LedgerCleaner.cpp b/src/ripple/app/ledger/impl/LedgerCleaner.cpp index 44bd65f0bb..daf7195dfe 100644 --- a/src/ripple/app/ledger/impl/LedgerCleaner.cpp +++ b/src/ripple/app/ledger/impl/LedgerCleaner.cpp @@ -319,7 +319,7 @@ public: doTxns = true; } - if (doNodes && !nodeLedger->walkLedger()) + if (doNodes && !nodeLedger->walkLedger(app_.journal ("Ledger"))) { m_journal.debug << "Ledger " << ledgerIndex << " is missing nodes"; app_.getInboundLedgers().acquire( diff --git a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp index de1580af00..5c71b203e4 100644 --- a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp +++ b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp @@ -76,12 +76,13 @@ bool shouldCloseLedger ( int previousMSeconds, int currentMSeconds, int openMSeconds, - int idleInterval) + int idleInterval, + beast::Journal j) { if ((previousMSeconds < -1000) || (previousMSeconds > 600000) || (currentMSeconds < -1000) || (currentMSeconds > 600000)) { - WriteLog (lsWARNING, LedgerTiming) << + JLOG (j.warning) << "shouldCloseLedger Trans=" << (anyTransactions ? "yes" : "no") << " Prop: " << previousProposers << "/" << proposersClosed << " Secs: " << currentMSeconds << " (last: " << @@ -94,7 +95,7 @@ bool shouldCloseLedger ( // did we miss a transaction? if (proposersClosed > (previousProposers / 4)) { - WriteLog (lsTRACE, LedgerTiming) << + JLOG (j.trace) << "no transactions, many proposers: now (" << proposersClosed << " closed, " << previousProposers << " before)"; return true; @@ -109,7 +110,7 @@ bool shouldCloseLedger ( { if ((proposersClosed + proposersValidated) < (previousProposers / 2 )) { - WriteLog (lsDEBUG, LedgerTiming) << + JLOG (j.debug) << "Must wait minimum time before closing"; return false; } @@ -119,7 +120,7 @@ bool shouldCloseLedger ( { if ((proposersClosed + proposersValidated) < previousProposers) { - WriteLog (lsDEBUG, LedgerTiming) << + JLOG (j.debug) << "We are waiting for more closes/validations"; return false; } @@ -161,9 +162,10 @@ ConsensusState checkConsensus ( int currentAgree, int currentFinished, int previousAgreeTime, - int currentAgreeTime) + int currentAgreeTime, + beast::Journal j) { - WriteLog (lsTRACE, LedgerTiming) << + JLOG (j.trace) << "checkConsensus: prop=" << currentProposers << "/" << previousProposers << " agree=" << currentAgree << " validated=" << currentFinished << @@ -178,7 +180,7 @@ ConsensusState checkConsensus ( // rush: we may need more time. if (currentAgreeTime < (previousAgreeTime + LEDGER_MIN_CONSENSUS)) { - WriteLog (lsTRACE, LedgerTiming) << + JLOG (j.trace) << "too fast, not enough proposers"; return ConsensusState::No; } @@ -188,7 +190,7 @@ ConsensusState checkConsensus ( // to declare consensus? if (checkConsensusReached (currentAgree + 1, currentProposers)) { - WriteLog (lsDEBUG, LedgerTiming) << "normal consensus"; + JLOG (j.debug) << "normal consensus"; return ConsensusState::Yes; } @@ -196,13 +198,13 @@ ConsensusState checkConsensus ( // to declare consensus? if (checkConsensusReached (currentFinished, currentProposers)) { - WriteLog (lsWARNING, LedgerTiming) << + JLOG (j.warning) << "We see no consensus, but 80% of nodes have moved on"; return ConsensusState::MovedOn; } // no consensus yet - WriteLog (lsTRACE, LedgerTiming) << "no consensus"; + JLOG (j.trace) << "no consensus"; return ConsensusState::No; } @@ -237,9 +239,10 @@ LedgerConsensusImp::LedgerConsensusImp ( , mConsensusStartTime (std::chrono::steady_clock::now ()) , mPreviousProposers (previousProposers) , mPreviousMSeconds (previousConvergeTime) + , j_ (app.journal ("LedgerConsensus")) { - WriteLog (lsDEBUG, LedgerConsensus) << "Creating consensus object"; - WriteLog (lsTRACE, LedgerConsensus) + JLOG (j_.debug) << "Creating consensus object"; + JLOG (j_.trace) << "LCL:" << previousLedger->getHash () << ", ct=" << closeTime; assert (mPreviousMSeconds); @@ -257,7 +260,7 @@ LedgerConsensusImp::LedgerConsensusImp ( { // If the validation keys were set, and if we need a ledger, // then we want to validate, and possibly propose a ledger. - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "Entering consensus process, validating"; mValidating = true; // Propose if we are in sync with the network @@ -267,7 +270,7 @@ LedgerConsensusImp::LedgerConsensusImp ( else { // Otherwise we just want to monitor the validation process. - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "Entering consensus process, watching"; mProposing = mValidating = false; } @@ -284,10 +287,10 @@ LedgerConsensusImp::LedgerConsensusImp ( if (!mHaveCorrectLCL) { // mProposing = mValidating = false; - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "Entering consensus with: " << previousLedger->getHash (); - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "Correct LCL is: " << prevLCLHash; } } @@ -427,7 +430,7 @@ void LedgerConsensusImp::mapCompleteInternal ( { // this is an invalid/corrupt map mAcquired[hash] = map; - WriteLog (lsWARNING, LedgerConsensus) + JLOG (j_.warning) << "A trusted node directed us to acquire an invalid TXN map"; return; } @@ -477,7 +480,7 @@ void LedgerConsensusImp::mapCompleteInternal ( assert (false); // We don't have our own position?! } else - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.warning) << "Not ready to create disputes"; mAcquired[hash] = map; @@ -514,7 +517,7 @@ void LedgerConsensusImp::mapComplete ( catch (SHAMapMissingNode const& mn) { leaveConsensus(); - WriteLog (lsERROR, LedgerConsensus) << + JLOG (j_.error) << "Missing node processing complete map " << mn; throw; } @@ -574,21 +577,21 @@ void LedgerConsensusImp::checkLCL () status = "unknown"; } - WriteLog (lsWARNING, LedgerConsensus) + JLOG (j_.warning) << "View of consensus changed during " << status << " (" << netLgrCount << ") status=" << status << ", " << (mHaveCorrectLCL ? "CorrectLCL" : "IncorrectLCL"); - WriteLog (lsWARNING, LedgerConsensus) << mPrevLedgerHash + JLOG (j_.warning) << mPrevLedgerHash << " to " << netLgr; - WriteLog (lsWARNING, LedgerConsensus) + JLOG (j_.warning) << ripple::getJson (*mPreviousLedger); if (ShouldLog (lsDEBUG, LedgerConsensus)) { for (auto& it : vals) { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "V: " << it.first << ", " << it.second.first; } } @@ -614,7 +617,7 @@ void LedgerConsensusImp::handleLCL (uint256 const& lclHash) if (mHaveCorrectLCL && mProposing && mOurPosition) { - WriteLog (lsINFO, LedgerConsensus) << "Bowing out of consensus"; + JLOG (j_.info) << "Bowing out of consensus"; mOurPosition->bowOut (); propose (); } @@ -639,7 +642,7 @@ void LedgerConsensusImp::handleLCL (uint256 const& lclHash) if (mAcquiringLedger != lclHash) { // need to start acquiring the correct consensus LCL - WriteLog (lsWARNING, LedgerConsensus) << + JLOG (j_.warning) << "Need consensus ledger " << mPrevLedgerHash; // Tell the ledger acquire system that we need the consensus ledger @@ -662,7 +665,7 @@ void LedgerConsensusImp::handleLCL (uint256 const& lclHash) mPreviousLedger = newLCL; mPrevLedgerHash = lclHash; - WriteLog (lsINFO, LedgerConsensus) << + JLOG (j_.info) << "Have the consensus ledger " << mPrevLedgerHash; mHaveCorrectLCL = true; @@ -713,7 +716,7 @@ void LedgerConsensusImp::timerEntry () catch (SHAMapMissingNode const& mn) { leaveConsensus (); - WriteLog (lsERROR, LedgerConsensus) << + JLOG (j_.error) << "Missing node during consensus process " << mn; throw; } @@ -760,7 +763,7 @@ void LedgerConsensusImp::statePreClose () if (shouldCloseLedger (anyTransactions , mPreviousProposers, proposersClosed, proposersValidated , mPreviousMSeconds, sinceClose, mCurrentMSeconds - , idleInterval)) + , idleInterval, app_.journal ("LedgerTiming"))) { closeLedger (); } @@ -780,12 +783,12 @@ void LedgerConsensusImp::stateEstablish () if (!mHaveCloseTimeConsensus) { - WriteLog (lsINFO, LedgerConsensus) << + JLOG (j_.info) << "We have TX consensus but not CT consensus"; return; } - WriteLog (lsINFO, LedgerConsensus) << + JLOG (j_.info) << "Converge cutoff (" << mPeerPositions.size () << " participants)"; state_ = State::finished; beginAccept (false); @@ -821,13 +824,13 @@ bool LedgerConsensusImp::haveConsensus () } else { - WriteLog (lsDEBUG, LedgerConsensus) << to_string (it.first) + JLOG (j_.debug) << to_string (it.first) << " has " << to_string (it.second->getCurrentHash ()); ++disagree; if (mCompares.count(it.second->getCurrentHash()) == 0) { // Make sure we have generated disputes uint256 hash = it.second->getCurrentHash(); - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "We have not compared to " << hash; auto it1 = mAcquired.find (hash); auto it2 = mAcquired.find(mOurPosition->getCurrentHash ()); @@ -844,13 +847,14 @@ bool LedgerConsensusImp::haveConsensus () int currentValidations = app_.getValidations () .getNodesAfter (mPrevLedgerHash); - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Checking for TX consensus: agree=" << agree << ", disagree=" << disagree; // Determine if we actually have consensus or not auto ret = checkConsensus (mPreviousProposers, agree + disagree, agree, - currentValidations, mPreviousMSeconds, mCurrentMSeconds); + currentValidations, mPreviousMSeconds, mCurrentMSeconds, + app_.journal ("LedgerTiming")); if (ret == ConsensusState::No) return false; @@ -886,7 +890,7 @@ bool LedgerConsensusImp::peerPosition (LedgerProposal::ref newPosition) if (mDeadNodes.find (peerID) != mDeadNodes.end ()) { - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "Position from dead node: " << to_string (peerID); return false; } @@ -906,7 +910,7 @@ bool LedgerConsensusImp::peerPosition (LedgerProposal::ref newPosition) if (newPosition->isBowOut ()) { - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "Peer bows out: " << to_string (peerID); for (auto& it : mDisputes) it.second->unVote (peerID); @@ -918,13 +922,13 @@ bool LedgerConsensusImp::peerPosition (LedgerProposal::ref newPosition) if (newPosition->isInitial ()) { // Record the close time estimate - WriteLog (lsTRACE, LedgerConsensus) + JLOG (j_.trace) << "Peer reports close time as " << newPosition->getCloseTime (); ++mCloseTimes[newPosition->getCloseTime ()]; } - WriteLog (lsTRACE, LedgerConsensus) << "Processing peer proposal " + JLOG (j_.trace) << "Processing peer proposal " << newPosition->getProposeSeq () << "/" << newPosition->getCurrentHash (); currentPosition = newPosition; @@ -939,7 +943,7 @@ bool LedgerConsensusImp::peerPosition (LedgerProposal::ref newPosition) } else { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Don't have tx set for peer"; } @@ -948,12 +952,12 @@ bool LedgerConsensusImp::peerPosition (LedgerProposal::ref newPosition) void LedgerConsensusImp::simulate () { - WriteLog (lsINFO, LedgerConsensus) << "Simulating consensus"; + JLOG (j_.info) << "Simulating consensus"; closeLedger (); mCurrentMSeconds = 100; beginAccept (true); endConsensus (); - WriteLog (lsINFO, LedgerConsensus) << "Simulation complete"; + JLOG (j_.info) << "Simulation complete"; } void LedgerConsensusImp::accept (std::shared_ptr set) @@ -1001,15 +1005,15 @@ void LedgerConsensusImp::accept (std::shared_ptr set) closeTime = mPreviousLedger->info().closeTime + 1; } - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Report: Prop=" << (mProposing ? "yes" : "no") << " val=" << (mValidating ? "yes" : "no") << " corLCL=" << (mHaveCorrectLCL ? "yes" : "no") << " fail=" << (mConsensusFail ? "yes" : "no"); - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Report: Prev = " << mPrevLedgerHash << ":" << mPreviousLedger->info().seq; - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Report: TxSt = " << set->getHash () << ", close " << closeTime << (closeTimeCorrect ? "" : "X"); @@ -1024,7 +1028,7 @@ void LedgerConsensusImp::accept (std::shared_ptr set) // Set up to write SHAMap changes to our database, // perform updates, extract changes - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Applying consensus set transactions to the" << " last closed ledger"; @@ -1035,7 +1039,7 @@ void LedgerConsensusImp::accept (std::shared_ptr set) { // Special case, we are replaying a ledger close for (auto& tx : replay->txns_) - applyTransaction (app_, accum, tx.second, false, tapNO_CHECK_SIGN); + applyTransaction (app_, accum, tx.second, false, tapNO_CHECK_SIGN, j_); } else { @@ -1056,7 +1060,7 @@ void LedgerConsensusImp::accept (std::shared_ptr set) hotACCOUNT_NODE, newLCL->info().seq); int tmf = newLCL->txMap().flushDirty ( hotTRANSACTION_NODE, newLCL->info().seq); - WriteLog (lsDEBUG, LedgerConsensus) << "Flushed " << + JLOG (j_.debug) << "Flushed " << asf << " accounts and " << tmf << " transaction nodes"; @@ -1065,17 +1069,17 @@ void LedgerConsensusImp::accept (std::shared_ptr set) // And stash the ledger in the ledger master if (ledgerMaster_.storeLedger (newLCL)) - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Consensus built ledger we already had"; else if (app_.getInboundLedgers().find (newLCL->getHash())) - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Consensus built ledger we were acquiring"; else - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Consensus built new ledger"; uint256 const newLCLHash = newLCL->getHash (); - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Report: NewL = " << newLCL->getHash () << ":" << newLCL->info().seq; // Tell directly connected peers that we have a new LCL @@ -1083,7 +1087,7 @@ void LedgerConsensusImp::accept (std::shared_ptr set) if (mValidating && ! ledgerMaster_.isCompatible (newLCL, - app_.logs().journal("LedgerConsensus").warning, + app_.journal("LedgerConsensus").warning, "Not validating")) { mValidating = false; @@ -1118,11 +1122,11 @@ void LedgerConsensusImp::accept (std::shared_ptr set) val.set_validation (&validation[0], validation.size ()); // Send signed validation to all of our directly connected peers app_.overlay().send(val); - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "CNF Val " << newLCLHash; } else - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "CNF newLCL " << newLCLHash; // See if we can accept a ledger as fully-validated @@ -1153,7 +1157,7 @@ void LedgerConsensusImp::accept (std::shared_ptr set) // we voted NO try { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Test applying disputed transaction that did" << " not get in"; SerialIter sit (it.second->peekTransaction().slice()); @@ -1166,7 +1170,7 @@ void LedgerConsensusImp::accept (std::shared_ptr set) } catch (...) { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Failed to apply transaction we voted NO on"; } } @@ -1205,7 +1209,7 @@ void LedgerConsensusImp::accept (std::shared_ptr set) { // see how close our close time is to other node's // close time reports, and update our clock. - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "We closed at " << mCloseTime; std::uint64_t closeTotal = mCloseTime; int closeCount = 1; @@ -1214,7 +1218,7 @@ void LedgerConsensusImp::accept (std::shared_ptr set) , end = mCloseTimes.end (); it != end; ++it) { // FIXME: Use median, not average - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << beast::lexicalCastThrow (it->second) << " time votes for " << beast::lexicalCastThrow (it->first); @@ -1227,7 +1231,7 @@ void LedgerConsensusImp::accept (std::shared_ptr set) closeTotal /= closeCount; int offset = static_cast (closeTotal) - static_cast (mCloseTime); - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "Our close offset is estimated at " << offset << " (" << closeCount << ")"; app_.timeKeeper().adjustCloseTime( @@ -1242,7 +1246,7 @@ void LedgerConsensusImp::createDisputes ( if (m1->getHash() == m2->getHash()) return; - WriteLog (lsDEBUG, LedgerConsensus) << "createDisputes " + JLOG (j_.debug) << "createDisputes " << m1->getHash() << " to " << m2->getHash(); SHAMap::Delta differences; m1->compare (*m2, differences, 16384); @@ -1270,7 +1274,7 @@ void LedgerConsensusImp::createDisputes ( else // No other disagreement over a transaction should be possible assert (false); } - WriteLog (lsDEBUG, LedgerConsensus) << dc << " differences found"; + JLOG (j_.debug) << dc << " differences found"; } void LedgerConsensusImp::addDisputedTransaction ( @@ -1280,7 +1284,7 @@ void LedgerConsensusImp::addDisputedTransaction ( if (mDisputes.find (txID) != mDisputes.end ()) return; - WriteLog (lsDEBUG, LedgerConsensus) << "Transaction " + JLOG (j_.debug) << "Transaction " << txID << " is disputed"; bool ourVote = false; @@ -1296,7 +1300,7 @@ void LedgerConsensusImp::addDisputedTransaction ( assert (false); // We don't have our own position? } - auto txn = std::make_shared (txID, tx, ourVote); + auto txn = std::make_shared (txID, tx, ourVote, j_); mDisputes[txID] = txn; // Update all of the peer's votes on the disputed transaction @@ -1350,7 +1354,7 @@ void LedgerConsensusImp::leaveConsensus () void LedgerConsensusImp::propose () { - WriteLog (lsTRACE, LedgerConsensus) << "We propose: " << + JLOG (j_.trace) << "We propose: " << (mOurPosition->isBowOut () ? std::string ("bowOut") : to_string (mOurPosition->getCurrentHash ())); @@ -1417,7 +1421,7 @@ void LedgerConsensusImp::statusChange ( app_.overlay ().foreach (send_always ( std::make_shared ( s, protocol::mtSTATUS_CHANGE))); - WriteLog (lsTRACE, LedgerConsensus) << "send status change to peer"; + JLOG (j_.trace) << "send status change to peer"; } void LedgerConsensusImp::takeInitialPosition ( @@ -1453,7 +1457,7 @@ void LedgerConsensusImp::takeInitialPosition ( ledgerMaster_.setBuildingLedger (mPreviousLedger->info().seq + 1); uint256 txSet = initialSet->getHash (); - WriteLog (lsINFO, LedgerConsensus) << "initial position " << txSet; + JLOG (j_.info) << "initial position " << txSet; mapCompleteInternal (txSet, initialSet, false); mOurPosition = std::make_shared @@ -1531,7 +1535,7 @@ void LedgerConsensusImp::updateOurPositions () { // peer's proposal is stale, so remove it auto const& peerID = it->second->getPeerID (); - WriteLog (lsWARNING, LedgerConsensus) + JLOG (j_.warning) << "Removing stale proposal from " << peerID; for (auto& dt : mDisputes) dt.second->unVote (peerID); @@ -1614,21 +1618,21 @@ void LedgerConsensusImp::updateOurPositions () int const threshConsensus = participantsNeeded ( participants, AV_CT_CONSENSUS_PCT); - WriteLog (lsINFO, LedgerConsensus) << "Proposers:" + JLOG (j_.info) << "Proposers:" << mPeerPositions.size () << " nw:" << neededWeight << " thrV:" << threshVote << " thrC:" << threshConsensus; for (auto it = closeTimes.begin () , end = closeTimes.end (); it != end; ++it) { - WriteLog (lsDEBUG, LedgerConsensus) << "CCTime: seq" + JLOG (j_.debug) << "CCTime: seq" << mPreviousLedger->info().seq + 1 << ": " << it->first << " has " << it->second << ", " << threshVote << " required"; if (it->second >= threshVote) { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j_.debug) << "Close time consensus reached: " << it->first; closeTime = it->first; threshVote = it->second; @@ -1666,7 +1670,7 @@ void LedgerConsensusImp::updateOurPositions () if (changes) { uint256 newHash = ourPosition->getHash (); - WriteLog (lsINFO, LedgerConsensus) + JLOG (j_.info) << "Position change: CTime " << closeTime << ", tx " << newHash; @@ -1689,7 +1693,7 @@ void LedgerConsensusImp::playbackProposals () if (proposal->isPrevLedger (mPrevLedgerHash) && peerPosition (proposal)) { - WriteLog (lsWARNING, LedgerConsensus) + JLOG (j_.warning) << "We should do delayed relay of this proposal," << " but we cannot"; } @@ -1747,7 +1751,7 @@ void LedgerConsensusImp::checkOurValidation () protocol::TMValidation val; val.set_validation (&validation[0], validation.size ()); consensus_.setLastValidation (v); - WriteLog (lsWARNING, LedgerConsensus) << "Sending partial validation"; + JLOG (j_.warning) << "Sending partial validation"; } void LedgerConsensusImp::beginAccept (bool synchronous) @@ -1756,7 +1760,7 @@ void LedgerConsensusImp::beginAccept (bool synchronous) if (!consensusSet) { - WriteLog (lsFATAL, LedgerConsensus) + JLOG (j_.fatal) << "We don't have a consensus set"; abort (); return; @@ -1808,7 +1812,8 @@ make_LedgerConsensus (Application& app, ConsensusImp& consensus, int previousPro int applyTransaction (Application& app, OpenView& view, std::shared_ptr const& txn, - bool retryAssured, ApplyFlags flags) + bool retryAssured, ApplyFlags flags, + beast::Journal j) { // Returns false if the transaction has need not be retried. if (retryAssured) @@ -1818,21 +1823,21 @@ applyTransaction (Application& app, OpenView& view, & SF_SIGGOOD) == SF_SIGGOOD) flags = flags | tapNO_CHECK_SIGN; - WriteLog (lsDEBUG, LedgerConsensus) << "TXN " + JLOG (j.debug) << "TXN " << txn->getTransactionID () //<< (engine.view().open() ? " open" : " closed") // because of the optional in engine << (retryAssured ? "/retry" : "/final"); - WriteLog (lsTRACE, LedgerConsensus) << txn->getJson (0); + JLOG (j.trace) << txn->getJson (0); try { auto const result = apply(app, view, *txn, flags, app.getHashRouter().sigVerify(), - app.config(), app.logs().journal("LedgerConsensus")); + app.config(), j); if (result.second) { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j.debug) << "Transaction applied: " << transHuman (result.first); return LedgerConsensusImp::resultSuccess; } @@ -1841,18 +1846,18 @@ applyTransaction (Application& app, OpenView& view, isTelLocal (result.first)) { // failure - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j.debug) << "Transaction failure: " << transHuman (result.first); return LedgerConsensusImp::resultFail; } - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (j.debug) << "Transaction retry: " << transHuman (result.first); return LedgerConsensusImp::resultRetry; } catch (...) { - WriteLog (lsWARNING, LedgerConsensus) << "Throws"; + JLOG (j.warning) << "Throws"; return LedgerConsensusImp::resultFail; } } @@ -1865,6 +1870,7 @@ void applyTransactions ( CanonicalTXSet& retriableTxs, ApplyFlags flags) { + auto j = app.journal ("LedgerConsensus"); if (set) { for (auto const& item : *set) @@ -1873,7 +1879,7 @@ void applyTransactions ( continue; // The transaction isn't in the check ledger, try to apply it - WriteLog (lsDEBUG, LedgerConsensus) << + JLOG (j.debug) << "Processing candidate transaction: " << item.key(); std::shared_ptr txn; try @@ -1882,12 +1888,12 @@ void applyTransactions ( } catch (...) { - WriteLog (lsWARNING, LedgerConsensus) << " Throws"; + JLOG (j.warning) << " Throws"; } if (txn) { - if (applyTransaction(app, view, txn, true, flags) == + if (applyTransaction(app, view, txn, true, flags, j) == LedgerConsensusImp::resultRetry) { // On failure, stash the failed transaction for @@ -1902,7 +1908,7 @@ void applyTransactions ( // Attempt to apply all of the retriable transactions for (int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass) { - WriteLog (lsDEBUG, LedgerConsensus) << "Pass: " << pass << " Txns: " + JLOG (j.debug) << "Pass: " << pass << " Txns: " << retriableTxs.size () << (certainRetry ? " retriable" : " final"); int changes = 0; @@ -1914,7 +1920,7 @@ void applyTransactions ( try { switch (applyTransaction (app, view, - it->second, certainRetry, flags)) + it->second, certainRetry, flags, j)) { case LedgerConsensusImp::resultSuccess: it = retriableTxs.erase (it); @@ -1931,13 +1937,13 @@ void applyTransactions ( } catch (...) { - WriteLog (lsWARNING, LedgerConsensus) + JLOG (j.warning) << "Transaction throws"; it = retriableTxs.erase (it); } } - WriteLog (lsDEBUG, LedgerConsensus) << "Pass: " + JLOG (j.debug) << "Pass: " << pass << " finished " << changes << " changes"; // A non-retry pass made no changes diff --git a/src/ripple/app/ledger/impl/LedgerConsensusImp.h b/src/ripple/app/ledger/impl/LedgerConsensusImp.h index f65728a5b8..c6b335bfb8 100644 --- a/src/ripple/app/ledger/impl/LedgerConsensusImp.h +++ b/src/ripple/app/ledger/impl/LedgerConsensusImp.h @@ -340,6 +340,7 @@ private: // nodes that have bowed out of this consensus process hash_set mDeadNodes; + beast::Journal j_; }; //------------------------------------------------------------------------------ diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index 8088869209..b81911feff 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, app_.logs().journal("LedgerCleaner"))) + app, *this, app_.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, - app_.logs().journal("TaggedCache")) + app_.journal("TaggedCache")) , fetch_seq_ (0) { } @@ -219,7 +219,7 @@ public: std::uint32_t pubClose = mPubLedgerClose.load(); if (!pubClose) { - WriteLog (lsDEBUG, LedgerMaster) << "No published ledger"; + JLOG (m_journal.debug) << "No published ledger"; return 999999; } @@ -228,7 +228,7 @@ public: ret -= static_cast (pubClose); ret = (ret > 0) ? ret : 0; - WriteLog (lsTRACE, LedgerMaster) << "Published ledger age is " << ret; + JLOG (m_journal.trace) << "Published ledger age is " << ret; return static_cast (ret); } @@ -237,7 +237,7 @@ public: std::uint32_t valClose = mValidLedgerSign.load(); if (!valClose) { - WriteLog (lsDEBUG, LedgerMaster) << "No validated ledger"; + JLOG (m_journal.debug) << "No validated ledger"; return 999999; } @@ -245,7 +245,7 @@ public: ret -= static_cast (valClose); ret = (ret > 0) ? ret : 0; - WriteLog (lsTRACE, LedgerMaster) << "Validated ledger age is " << ret; + JLOG (m_journal.trace) << "Validated ledger age is " << ret; return static_cast (ret); } @@ -569,7 +569,7 @@ public: if (haveHash.isZero()) { - WriteLog (lsERROR, LedgerMaster) << "No hash for fetch pack"; + JLOG (m_journal.error) << "No hash for fetch pack"; return; } @@ -603,11 +603,11 @@ public: tmBH, protocol::mtGET_OBJECTS); target->send (packet); - WriteLog (lsTRACE, LedgerMaster) << "Requested fetch pack for " + JLOG (m_journal.trace) << "Requested fetch pack for " << missingIndex; } else - WriteLog (lsDEBUG, LedgerMaster) << "No peer for fetch pack"; + JLOG (m_journal.debug) << "No peer for fetch pack"; } void fixMismatch (Ledger::ref ledger) override @@ -625,7 +625,7 @@ public: } catch (...) { - WriteLog (lsWARNING, LedgerMaster) << + JLOG (m_journal.warning) << "fixMismatch encounters partial ledger"; clearLedger(lSeq); return; @@ -660,8 +660,8 @@ public: Ledger::pointer ledger, bool isSynchronous, bool isCurrent) override { // A new ledger has been accepted as part of the trusted chain - WriteLog (lsDEBUG, LedgerMaster) << "Ledger " << ledger->info().seq - << " accepted :" << ledger->getHash (); + JLOG (m_journal.debug) << "Ledger " << ledger->info().seq + << "accepted :" << ledger->getHash (); assert (ledger->stateMap().getHash ().isNonZero ()); ledger->setValidated(); @@ -706,7 +706,7 @@ public: if (!prevLedger || (prevLedger->getHash () != ledger->info().parentHash)) { - WriteLog (lsWARNING, LedgerMaster) + JLOG (m_journal.warning) << "Acquired ledger invalidates previous ledger: " << (prevLedger ? "hashMismatch" : "missingLedger"); fixMismatch (ledger); @@ -747,7 +747,7 @@ public: if (mMinValidations < (valCount/2 + 1)) { mMinValidations = (valCount/2 + 1); - WriteLog (lsINFO, LedgerMaster) + JLOG (m_journal.info) << "Raising minimum validations to " << mMinValidations; } } @@ -824,12 +824,12 @@ public: ledger->getHash()); if (tvc < minVal) // nothing we can do { - WriteLog (lsTRACE, LedgerMaster) + JLOG (m_journal.trace) << "Only " << tvc << " validations for " << ledger->getHash(); return; } - WriteLog (lsINFO, LedgerMaster) + JLOG (m_journal.info) << "Advancing accepted ledger to " << ledger->info().seq << " with >= " << minVal << " validations"; @@ -883,7 +883,7 @@ public: if (ledger->info().seq <= mValidLedgerSeq) { - WriteLog (lsINFO, LedgerConsensus) + JLOG (app_.journal ("LedgerConsensus").info) << "Consensus built old ledger: " << ledger->info().seq << " <= " << mValidLedgerSeq; return; @@ -894,7 +894,7 @@ public: if (ledger->info().seq <= mValidLedgerSeq) { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (app_.journal ("LedgerConsensus").debug) << "Consensus ledger fully validated"; return; } @@ -959,7 +959,7 @@ public: if (maxSeq > mValidLedgerSeq) { - WriteLog (lsDEBUG, LedgerConsensus) + JLOG (app_.journal ("LedgerConsensus").debug) << "Consensus triggered check of ledger"; checkAccept (maxLedger, maxSeq); } @@ -970,7 +970,7 @@ public: ScopedLockType sl (m_mutex); assert (!mValidLedger.empty () && mAdvanceThread); - WriteLog (lsTRACE, LedgerMaster) << "advanceThread<"; + JLOG (m_journal.trace) << "advanceThread<"; try { @@ -978,11 +978,11 @@ public: } catch (...) { - WriteLog (lsFATAL, LedgerMaster) << "doAdvance throws an exception"; + JLOG (m_journal.fatal) << "doAdvance throws an exception"; } mAdvanceThread = false; - WriteLog (lsTRACE, LedgerMaster) << "advanceThread>"; + JLOG (m_journal.trace) << "advanceThread>"; } // VFALCO NOTE This should return boost::optional @@ -1022,20 +1022,20 @@ public: { std::vector ret; - WriteLog (lsTRACE, LedgerMaster) << "findNewLedgersToPublish<"; + JLOG (m_journal.trace) << "findNewLedgersToPublish<"; if (mValidLedger.empty ()) { // No valid ledger, nothing to do } else if (! mPubLedger) { - WriteLog (lsINFO, LedgerMaster) << "First published ledger will be " + JLOG (m_journal.info) << "First published ledger will be " << mValidLedgerSeq; ret.push_back (mValidLedger.get ()); } else if (mValidLedgerSeq > (mPubLedgerSeq + MAX_LEDGER_GAP)) { - WriteLog (lsWARNING, LedgerMaster) + JLOG (m_journal.warning) << "Gap in validated ledger stream " << mPubLedgerSeq << " - " << mValidLedgerSeq - 1; Ledger::pointer valLedger = mValidLedger.get (); @@ -1056,7 +1056,7 @@ public: { for (std::uint32_t seq = pubSeq; seq <= valSeq; ++seq) { - WriteLog (lsTRACE, LedgerMaster) + JLOG (m_journal.trace) << "Trying to fetch/publish valid ledger " << seq; Ledger::pointer ledger; @@ -1073,7 +1073,7 @@ public: } else if (hash->isZero()) { - WriteLog (lsFATAL, LedgerMaster) + JLOG (m_journal.fatal) << "Ledger: " << valSeq << " does not have hash for " << seq; assert (false); @@ -1100,12 +1100,12 @@ public: } catch (...) { - WriteLog (lsERROR, LedgerMaster) + JLOG (m_journal.error) << "findNewLedgersToPublish catches an exception"; } } - WriteLog (lsTRACE, LedgerMaster) + JLOG (m_journal.trace) << "findNewLedgersToPublish> " << ret.size(); return ret; } @@ -1204,7 +1204,7 @@ public: age -= static_cast (lastLedger->info().closeTime); if (age > 60) { - WriteLog (lsDEBUG, LedgerMaster) + JLOG (m_journal.debug) << "Published ledger too old for updating paths"; --mPathFindThread; return; @@ -1218,7 +1218,7 @@ public: } catch (SHAMapMissingNode&) { - WriteLog (lsINFO, LedgerMaster) + JLOG (m_journal.info) << "Missing node detected during pathfinding"; if (lastLedger->info().open) { @@ -1340,7 +1340,7 @@ public: } catch (SHAMapMissingNode const&) { - WriteLog (lsWARNING, RPCHandler) + JLOG (app_.journal ("RPCHandler").warning) << "Missing SHANode " << std::to_string (seq); return false; } @@ -1357,7 +1357,7 @@ public: void setMinValidations (int v) override { - WriteLog (lsINFO, LedgerMaster) << "Validation quorum: " << v; + JLOG (m_journal.info) << "Validation quorum: " << v; mMinValidations = v; } @@ -1584,7 +1584,7 @@ bool LedgerMasterImp::shouldAcquire ( candidateLedger > ledgerHistoryIndex || (currentLedger - candidateLedger) <= ledgerHistory); - WriteLog (lsTRACE, LedgerMaster) + JLOG (m_journal.trace) << "Missing ledger " << candidateLedger << (ret ? " should" : " should NOT") @@ -1616,14 +1616,14 @@ void LedgerMasterImp::doAdvance () missing = mCompleteLedgers.prevMissing( mPubLedger->info().seq); } - WriteLog (lsTRACE, LedgerMaster) + JLOG (m_journal.trace) << "tryAdvance discovered missing " << missing; if ((missing != RangeSet::absent) && (missing > 0) && shouldAcquire (mValidLedgerSeq, ledger_history_, app_.getSHAMapStore ().getCanDelete (), missing) && ((mFillInProgress == 0) || (missing > mFillInProgress))) { - WriteLog (lsTRACE, LedgerMaster) + JLOG (m_journal.trace) << "advanceThread should acquire"; { ScopedUnlockType sl(m_mutex); @@ -1643,26 +1643,26 @@ void LedgerMasterImp::doAdvance () if (! ledger && (missing > 32600) && shouldFetchPack (missing)) { - WriteLog (lsTRACE, LedgerMaster) << + JLOG (m_journal.trace) << "tryAdvance want fetch pack " << missing; fetch_seq_ = missing; getFetchPack(hash, missing); } else - WriteLog (lsTRACE, LedgerMaster) << + JLOG (m_journal.trace) << "tryAdvance no fetch pack for " << missing; } else - WriteLog (lsDEBUG, LedgerMaster) << + JLOG (m_journal.debug) << "tryAdvance found failed acquire"; } if (ledger) { auto seq = ledger->info().seq; assert(seq == missing); - WriteLog (lsTRACE, LedgerMaster) + JLOG (m_journal.trace) << "tryAdvance acquired " << ledger->info().seq; setFullLedger(ledger, false, false); @@ -1699,19 +1699,19 @@ void LedgerMasterImp::doAdvance () } catch (...) { - WriteLog (lsWARNING, LedgerMaster) << + JLOG (m_journal.warning) << "Threw while prefetching"; } } } else { - WriteLog (lsFATAL, LedgerMaster) << + JLOG (m_journal.fatal) << "Can't find ledger following prevMissing " << missing; - WriteLog (lsFATAL, LedgerMaster) << "Pub:" << + JLOG (m_journal.fatal) << "Pub:" << mPubLedgerSeq << " Val:" << mValidLedgerSeq; - WriteLog (lsFATAL, LedgerMaster) << "Ledgers: " << + JLOG (m_journal.fatal) << "Ledgers: " << app_.getLedgerMaster().getCompleteLedgers(); clearLedger (missing + 1); progress = true; @@ -1719,7 +1719,7 @@ void LedgerMasterImp::doAdvance () } if (mValidLedgerSeq != mPubLedgerSeq) { - WriteLog (lsDEBUG, LedgerMaster) << + JLOG (m_journal.debug) << "tryAdvance found last valid changed"; progress = true; } @@ -1728,20 +1728,20 @@ void LedgerMasterImp::doAdvance () else { mHistLedger.reset(); - WriteLog (lsTRACE, LedgerMaster) << + JLOG (m_journal.trace) << "tryAdvance not fetching history"; } } else { - WriteLog (lsTRACE, LedgerMaster) << + JLOG (m_journal.trace) << "tryAdvance found " << pubLedgers.size() << " ledgers to publish"; for(auto ledger : pubLedgers) { { ScopedUnlockType sul (m_mutex); - WriteLog(lsDEBUG, LedgerMaster) << + JLOG (m_journal.debug) << "tryAdvance publishing seq " << ledger->info().seq; setFullLedger(ledger, true, true); diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index b5d8f4e154..32bf65c571 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -131,12 +131,12 @@ public: CollectorManager& collectorManager) : app_ (app) , treecache_ ("TreeNodeCache", 65536, 60, stopwatch(), - app.logs().journal("TaggedCache")) + app.journal("TaggedCache")) , fullbelow_ ("full_below", stopwatch(), collectorManager.collector(), fullBelowTargetSize, fullBelowExpirationSeconds) , db_ (db) - , j_ (app.logs().journal("SHAMap")) + , j_ (app.journal("SHAMap")) { } @@ -428,7 +428,7 @@ public: // almost everything is a Stoppable child of the JobQueue. // , m_jobQueue (make_JobQueue (m_collectorManager->group ("jobq"), - m_nodeStoreScheduler, logs_->journal("JobQueue"))) + m_nodeStoreScheduler, logs_->journal("JobQueue"), *logs_)) // // Anything which calls addJob must be a descendant of the JobQueue @@ -732,6 +732,8 @@ public: bool serverOkay (std::string& reason) override; + beast::Journal journal (std::string const& name) override; + //-------------------------------------------------------------------------- bool initSqliteDbs () { @@ -820,8 +822,8 @@ public: << boost::str (boost::format ("PRAGMA cache_size=-%d;") % (config_->getSize (siTxnDBCache) * 1024)); - mTxnDB->setupCheckpointing (m_jobQueue.get()); - mLedgerDB->setupCheckpointing (m_jobQueue.get()); + mTxnDB->setupCheckpointing (m_jobQueue.get(), logs()); + mLedgerDB->setupCheckpointing (m_jobQueue.get(), logs()); if (!config_->RUN_STANDALONE) updateTables (); @@ -1161,24 +1163,25 @@ ApplicationImp::getLastFullLedger() if (ledger->getHash () != ledgerHash) { - if (ShouldLog (lsERROR, Ledger)) + auto j = journal ("Ledger"); + if (j.error) { - WriteLog (lsERROR, Ledger) << "Failed on ledger"; + j.error << "Failed on ledger"; Json::Value p; addJson (p, {*ledger, LedgerFill::full}); - WriteLog (lsERROR, Ledger) << p; + j.error << p; } assert (false); return Ledger::pointer (); } - WriteLog (lsTRACE, Ledger) << "Loaded ledger: " << ledgerHash; + JLOG (journal ("Ledger").trace) << "Loaded ledger: " << ledgerHash; return ledger; } catch (SHAMapMissingNode& sn) { - WriteLog (lsWARNING, Ledger) + JLOG (journal ("Ledger").warning) << "Database contains ledger with missing nodes: " << sn; return Ledger::pointer (); } @@ -1367,14 +1370,14 @@ bool ApplicationImp::loadOldLedger ( return false; } - if (!loadLedger->walkLedger ()) + if (!loadLedger->walkLedger (journal ("Ledger"))) { m_journal.fatal << "Ledger is missing nodes."; assert(false); return false; } - if (!loadLedger->assertSane ()) + if (!loadLedger->assertSane (journal ("Ledger"))) { m_journal.fatal << "Ledger is not sane."; assert(false); @@ -1481,6 +1484,11 @@ bool ApplicationImp::serverOkay (std::string& reason) return true; } +beast::Journal ApplicationImp::journal (std::string const& name) +{ + return logs_->journal (name); +} + //VFALCO TODO clean this up since it is just a file holding a single member function definition static std::vector getSchema (DatabaseCon& dbc, std::string const& dbName) @@ -1504,13 +1512,15 @@ static std::vector getSchema (DatabaseCon& dbc, std::string const& return schema; } -static bool schemaHas (DatabaseCon& dbc, std::string const& dbName, int line, std::string const& content) +static bool schemaHas ( + DatabaseCon& dbc, std::string const& dbName, int line, + std::string const& content, beast::Journal j) { std::vector schema = getSchema (dbc, dbName); if (static_cast (schema.size ()) <= line) { - WriteLog (lsFATAL, Application) << "Schema for " << dbName << " has too few lines"; + JLOG (j.fatal) << "Schema for " << dbName << " has too few lines"; throw std::runtime_error ("bad schema"); } @@ -1519,17 +1529,17 @@ static bool schemaHas (DatabaseCon& dbc, std::string const& dbName, int line, st void ApplicationImp::addTxnSeqField () { - if (schemaHas (getTxnDB (), "AccountTransactions", 0, "TxnSeq")) + if (schemaHas (getTxnDB (), "AccountTransactions", 0, "TxnSeq", m_journal)) return; - WriteLog (lsWARNING, Application) << "Transaction sequence field is missing"; + JLOG (m_journal.warning) << "Transaction sequence field is missing"; auto& session = getTxnDB ().getSession (); std::vector< std::pair > txIDs; txIDs.reserve (300000); - WriteLog (lsINFO, Application) << "Parsing transactions"; + JLOG (m_journal.info) << "Parsing transactions"; int i = 0; uint256 transID; @@ -1558,28 +1568,28 @@ void ApplicationImp::addTxnSeqField () if (txnMeta.size () == 0) { txIDs.push_back (std::make_pair (transID, -1)); - WriteLog (lsINFO, Application) << "No metadata for " << transID; + JLOG (m_journal.info) << "No metadata for " << transID; } else { - TxMeta m (transID, 0, txnMeta); + TxMeta m (transID, 0, txnMeta, journal ("TxMeta")); txIDs.push_back (std::make_pair (transID, m.getIndex ())); } if ((++i % 1000) == 0) { - WriteLog (lsINFO, Application) << i << " transactions read"; + JLOG (m_journal.info) << i << " transactions read"; } } - WriteLog (lsINFO, Application) << "All " << i << " transactions read"; + JLOG (m_journal.info) << "All " << i << " transactions read"; soci::transaction tr(session); - WriteLog (lsINFO, Application) << "Dropping old index"; + JLOG (m_journal.info) << "Dropping old index"; session << "DROP INDEX AcctTxIndex;"; - WriteLog (lsINFO, Application) << "Altering table"; + JLOG (m_journal.info) << "Altering table"; session << "ALTER TABLE AccountTransactions ADD COLUMN TxnSeq INTEGER;"; boost::format fmt ("UPDATE AccountTransactions SET TxnSeq = %d WHERE TransID = '%s';"); @@ -1590,11 +1600,11 @@ void ApplicationImp::addTxnSeqField () if ((++i % 1000) == 0) { - WriteLog (lsINFO, Application) << i << " transactions updated"; + JLOG (m_journal.info) << i << " transactions updated"; } } - WriteLog (lsINFO, Application) << "Building new index"; + JLOG (m_journal.info) << "Building new index"; session << "CREATE INDEX AcctTxIndex ON AccountTransactions(Account, LedgerSeq, TxnSeq, TransID);"; tr.commit (); @@ -1604,18 +1614,18 @@ void ApplicationImp::updateTables () { if (config_->section (ConfigSection::nodeDatabase ()).empty ()) { - WriteLog (lsFATAL, Application) << "The [node_db] configuration setting has been updated and must be set"; + JLOG (m_journal.fatal) << "The [node_db] configuration setting has been updated and must be set"; exitWithCode(1); } // perform any needed table updates - assert (schemaHas (getTxnDB (), "AccountTransactions", 0, "TransID")); - assert (!schemaHas (getTxnDB (), "AccountTransactions", 0, "foobar")); + assert (schemaHas (getTxnDB (), "AccountTransactions", 0, "TransID", m_journal)); + assert (!schemaHas (getTxnDB (), "AccountTransactions", 0, "foobar", m_journal)); addTxnSeqField (); - if (schemaHas (getTxnDB (), "AccountTransactions", 0, "PRIMARY")) + if (schemaHas (getTxnDB (), "AccountTransactions", 0, "PRIMARY", m_journal)) { - WriteLog (lsFATAL, Application) << "AccountTransactions database should not have a primary key"; + JLOG (m_journal.fatal) << "AccountTransactions database should not have a primary key"; exitWithCode(1); } @@ -1627,9 +1637,9 @@ void ApplicationImp::updateTables () logs_->journal("NodeObject"), 0, config_->section(ConfigSection::importNodeDatabase ())); - WriteLog (lsWARNING, NodeObject) << - "Node import from '" << source->getName () << "' to '" - << getNodeStore().getName () << "'."; + JLOG (journal ("NodeObject").warning) + << "Node import from '" << source->getName () << "' to '" + << getNodeStore ().getName () << "'."; getNodeStore().import (*source); } diff --git a/src/ripple/app/main/Application.h b/src/ripple/app/main/Application.h index 0e844c7074..c459a50f78 100644 --- a/src/ripple/app/main/Application.h +++ b/src/ripple/app/main/Application.h @@ -129,6 +129,7 @@ public: virtual bool serverOkay (std::string& reason) = 0; + virtual beast::Journal journal (std::string const& name) = 0; /** Retrieve the "wallet database" It looks like this is used to store the unique node list. diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index 5709c9c805..f2ceece46f 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -95,7 +95,7 @@ void startServer (Application& app) Resource::Charge loadType = Resource::feeReferenceRPC; RPC::Context context { - jvCommand, app, loadType, app.getOPs (), + app.journal ("RPCHandler"), jvCommand, app, loadType, app.getOPs (), app.getLedgerMaster(), Role::ADMIN, app}; Json::Value jvResult; @@ -498,7 +498,7 @@ int run (int argc, char** argv) setCallingThreadName ("rpc"); return RPCCall::fromCommandLine ( *config, - vm["parameters"].as>()); + vm["parameters"].as>(), deprecatedLogs()); } extern int run (int argc, char** argv); diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 475943dde8..af4ded1f73 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -1685,7 +1685,8 @@ NetworkOPs::AccountTxs NetworkOPsImp::getAccountTxs ( } ret.emplace_back (txn, std::make_shared ( - txn->getID (), txn->getLedger (), txnMeta)); + txn->getID (), txn->getLedger (), txnMeta, + app_.journal ("TxMeta"))); } } @@ -2027,7 +2028,7 @@ void NetworkOPsImp::pubProposedTransaction ( } } AcceptedLedgerTx alt (lpCurrent, stTxn, terResult, - app_.accountIDCache()); + app_.accountIDCache(), app_.logs()); m_journal.trace << "pubProposed: " << alt.getJson (); pubAccountTransaction (lpCurrent, alt, false); } @@ -2042,7 +2043,7 @@ void NetworkOPsImp::pubLedger (Ledger::ref lpAccepted) if (! alpAccepted) { alpAccepted = std::make_shared ( - lpAccepted, app_.accountIDCache()); + lpAccepted, app_.accountIDCache(), app_.logs()); app_.getAcceptedLedgerCache().canonicalize ( lpAccepted->info().hash, alpAccepted); } @@ -2153,7 +2154,7 @@ Json::Value NetworkOPsImp::transJson( if (account != amount.issue ().account) { auto const ownerFunds = accountFunds(*lpCurrent, - account, amount, fhIGNORE_FREEZE); + account, amount, fhIGNORE_FREEZE, app_.journal ("View")); jvObj[jss::transaction][jss::owner_funds] = ownerFunds.getText (); } } @@ -2585,6 +2586,7 @@ void NetworkOPsImp::getBookPage ( STAmount saDirRate; auto uTransferRate = rippleTransferRate(view, book.out.account); + auto viewJ = app_.journal ("View"); unsigned int left (iLimit == 0 ? 300 : iLimit); if (! bAdmin && left > 300) @@ -2615,7 +2617,7 @@ void NetworkOPsImp::getBookPage ( saDirRate = amountFromQuality (getQuality (uTipIndex)); cdirFirst (view, - uTipIndex, sleOfferDir, uBookEntry, offerIndex); + uTipIndex, sleOfferDir, uBookEntry, offerIndex, viewJ); m_journal.trace << "getBookPage: uTipIndex=" << uTipIndex; m_journal.trace << "getBookPage: offerIndex=" << offerIndex; @@ -2665,7 +2667,7 @@ void NetworkOPsImp::getBookPage ( saOwnerFunds = accountHolds (view, uOfferOwnerID, book.out.currency, - book.out.account, fhZERO_IF_FROZEN); + book.out.account, fhZERO_IF_FROZEN, viewJ); if (saOwnerFunds < zero) { @@ -2745,7 +2747,7 @@ void NetworkOPsImp::getBookPage ( } if (! cdirNext(view, - uTipIndex, sleOfferDir, uBookEntry, offerIndex)) + uTipIndex, sleOfferDir, uBookEntry, offerIndex, viewJ)) { bDirectAdvance = true; } diff --git a/src/ripple/app/misc/UniqueNodeList.cpp b/src/ripple/app/misc/UniqueNodeList.cpp index 254a9578e4..2c1c9860b0 100644 --- a/src/ripple/app/misc/UniqueNodeList.cpp +++ b/src/ripple/app/misc/UniqueNodeList.cpp @@ -237,6 +237,7 @@ private: std::string node_file_name_; std::string node_file_path_; + beast::Journal j_; public: UniqueNodeListImp (Application& app, Stoppable& parent); @@ -410,6 +411,7 @@ UniqueNodeListImp::UniqueNodeListImp (Application& app, Stoppable& parent) , m_scoreTimer (this) , mFetchActive (0) , m_fetchTimer (this) + , j_ (app.journal ("UniqueNodeList")) { node_file_name_ = std::string (systemName ()) + ".txt"; node_file_path_ = "/" + node_file_name_; @@ -428,11 +430,11 @@ void UniqueNodeListImp::doScore() mtpScoreNext = boost::posix_time::ptime (boost::posix_time::not_a_date_time); // Timer not set. mtpScoreStart = boost::posix_time::second_clock::universal_time (); // Scoring. - WriteLog (lsTRACE, UniqueNodeList) << "Scoring: Start"; + JLOG (j_.trace) << "Scoring: Start"; scoreCompute (); - WriteLog (lsTRACE, UniqueNodeList) << "Scoring: End"; + JLOG (j_.trace) << "Scoring: End"; // Save update time. mtpScoreUpdated = mtpScoreStart; @@ -447,7 +449,7 @@ void UniqueNodeListImp::doScore() void UniqueNodeListImp::doFetch() { // Time to check for another fetch. - WriteLog (lsTRACE, UniqueNodeList) << "fetchTimerHandler"; + JLOG (j_.trace) << "fetchTimerHandler"; fetchNext (); } @@ -472,8 +474,8 @@ void UniqueNodeListImp::start() { miscLoad (); - WriteLog (lsDEBUG, UniqueNodeList) << "Validator fetch updated: " << mtpFetchUpdated; - WriteLog (lsDEBUG, UniqueNodeList) << "Validator score updated: " << mtpScoreUpdated; + JLOG (j_.debug) << "Validator fetch updated: " << mtpFetchUpdated; + JLOG (j_.debug) << "Validator score updated: " << mtpScoreUpdated; fetchNext (); // Start fetching. scoreNext (false); // Start scoring. @@ -541,7 +543,7 @@ void UniqueNodeListImp::nodeAddDomain (std::string strDomain, ValidatorSource vs boost::to_lower (strDomain); // YYY Would be best to verify strDomain is a valid domain. - // WriteLog (lsTRACE) << str(boost::format("nodeAddDomain: '%s' %c '%s'") + // JLOG (lsTRACE) << str(boost::format("nodeAddDomain: '%s' %c '%s'") // % strDomain // % vsWhy // % strComment); @@ -782,7 +784,7 @@ void UniqueNodeListImp::nodeBootstrap() // Always merge in the file specified in the config. if (!app_.config().VALIDATORS_FILE.empty ()) { - WriteLog (lsINFO, UniqueNodeList) << "Bootstrapping UNL: loading from unl_default."; + JLOG (j_.info) << "Bootstrapping UNL: loading from unl_default."; bLoaded = nodeLoad (app_.config().VALIDATORS_FILE); } @@ -790,7 +792,7 @@ void UniqueNodeListImp::nodeBootstrap() // If never loaded anything try the current directory. if (!bLoaded && app_.config().VALIDATORS_FILE.empty ()) { - WriteLog (lsINFO, UniqueNodeList) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.") + JLOG (j_.info) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.") % app_.config().VALIDATORS_BASE); bLoaded = nodeLoad (app_.config().VALIDATORS_BASE); @@ -801,7 +803,7 @@ void UniqueNodeListImp::nodeBootstrap() { RippleAddress naInvalid; // Don't want a referrer on added entries. - WriteLog (lsINFO, UniqueNodeList) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.") + JLOG (j_.info) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.") % app_.config().CONFIG_FILE); if (processValidators ("local", @@ -812,7 +814,7 @@ void UniqueNodeListImp::nodeBootstrap() if (!bLoaded) { - WriteLog (lsINFO, UniqueNodeList) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.") + JLOG (j_.info) << boost::str (boost::format ("Bootstrapping UNL: loading from '%s'.") % app_.config().VALIDATORS_SITE); nodeNetwork (); @@ -825,7 +827,7 @@ bool UniqueNodeListImp::nodeLoad (boost::filesystem::path pConfig) { if (pConfig.empty ()) { - WriteLog (lsINFO, UniqueNodeList) << Config::Helpers::getValidatorsFileName() << + JLOG (j_.info) << Config::Helpers::getValidatorsFileName() << " path not specified."; return false; @@ -833,7 +835,7 @@ bool UniqueNodeListImp::nodeLoad (boost::filesystem::path pConfig) if (!boost::filesystem::exists (pConfig)) { - WriteLog (lsWARNING, UniqueNodeList) << Config::Helpers::getValidatorsFileName() << + JLOG (j_.warning) << Config::Helpers::getValidatorsFileName() << " not found: " << pConfig; return false; @@ -841,7 +843,7 @@ bool UniqueNodeListImp::nodeLoad (boost::filesystem::path pConfig) if (!boost::filesystem::is_regular_file (pConfig)) { - WriteLog (lsWARNING, UniqueNodeList) << Config::Helpers::getValidatorsFileName() << + JLOG (j_.warning) << Config::Helpers::getValidatorsFileName() << " not regular file: " << pConfig; return false; @@ -851,7 +853,7 @@ bool UniqueNodeListImp::nodeLoad (boost::filesystem::path pConfig) if (!ifsDefault) { - WriteLog (lsFATAL, UniqueNodeList) << Config::Helpers::getValidatorsFileName() << + JLOG (j_.fatal) << Config::Helpers::getValidatorsFileName() << " failed to open: " << pConfig; return false; @@ -864,7 +866,7 @@ bool UniqueNodeListImp::nodeLoad (boost::filesystem::path pConfig) if (ifsDefault.bad ()) { - WriteLog (lsFATAL, UniqueNodeList) << Config::Helpers::getValidatorsFileName() << + JLOG (j_.fatal) << Config::Helpers::getValidatorsFileName() << "Failed to read: " << pConfig; return false; @@ -872,7 +874,7 @@ bool UniqueNodeListImp::nodeLoad (boost::filesystem::path pConfig) nodeProcess ("local", strValidators, pConfig.string ()); - WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("Processing: %s") % pConfig); + JLOG (j_.trace) << str (boost::format ("Processing: %s") % pConfig); return true; } @@ -894,7 +896,8 @@ void UniqueNodeListImp::nodeNetwork() std::bind (&UniqueNodeListImp::validatorsResponse, this, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); + std::placeholders::_3), + app_.logs()); } } @@ -1031,7 +1034,7 @@ void UniqueNodeListImp::trustedLoad() m_clusterNodes.insert (std::make_pair (a, ClusterNodeStatus(match[2]))); } else - WriteLog (lsWARNING, UniqueNodeList) << "Entry in cluster list invalid: '" << c << "'"; + JLOG (j_.warning) << "Entry in cluster list invalid: '" << c << "'"; } auto db = app_.getWalletDB ().checkoutDb (); @@ -1081,10 +1084,10 @@ bool UniqueNodeListImp::scoreRound (std::vector& vsnNodes) if (ShouldLog (lsTRACE, UniqueNodeList)) { - WriteLog (lsTRACE, UniqueNodeList) << "midway: "; + JLOG (j_.trace) << "midway: "; for (auto& sn : vsnNodes) { - WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("%s| %d, %d, %d: [%s]") + JLOG (j_.trace) << str (boost::format ("%s| %d, %d, %d: [%s]") % sn.strValidator % sn.iScore % sn.iRoundScore @@ -1107,10 +1110,10 @@ bool UniqueNodeListImp::scoreRound (std::vector& vsnNodes) if (ShouldLog (lsTRACE, UniqueNodeList)) { - WriteLog (lsTRACE, UniqueNodeList) << "finish: "; + JLOG (j_.trace) << "finish: "; for (auto& sn : vsnNodes) { - WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("%s| %d, %d, %d: [%s]") + JLOG (j_.trace) << str (boost::format ("%s| %d, %d, %d: [%s]") % sn.strValidator % sn.iScore % sn.iRoundScore @@ -1245,7 +1248,7 @@ void UniqueNodeListImp::scoreCompute() { for (auto& sn : vsnNodes) { - WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("%s| %d, %d, %d") + JLOG (j_.trace) << str (boost::format ("%s| %d, %d, %d") % sn.strValidator % sn.iScore % sn.iRoundScore @@ -1253,7 +1256,7 @@ void UniqueNodeListImp::scoreCompute() } } - // WriteLog (lsTRACE, UniqueNodeList) << str(boost::format("vsnNodes.size=%d") % vsnNodes.size()); + // JLOG (j_.trace) << str(boost::format("vsnNodes.size=%d") % vsnNodes.size()); // Step through growing list of nodes adding each validation list. // - Each validator may have provided referals. Add those referals as validators. @@ -1332,10 +1335,10 @@ void UniqueNodeListImp::scoreCompute() if (ShouldLog (lsTRACE, UniqueNodeList)) { - WriteLog (lsTRACE, UniqueNodeList) << "Scored:"; + JLOG (j_.trace) << "Scored:"; for (auto& sn : vsnNodes) { - WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("%s| %d, %d, %d: [%s]") + JLOG (j_.trace) << str (boost::format ("%s| %d, %d, %d: [%s]") % sn.strValidator % sn.iScore % sn.iRoundScore @@ -1433,7 +1436,7 @@ void UniqueNodeListImp::scoreCompute() { umValidators[get<0>(col).value_or("")] = get<1>(col).value_or(0); - // WriteLog (lsTRACE, UniqueNodeList) << strValidator << ":" << db->getInt("Count"); + // JLOG (j_.trace) << strValidator << ":" << db->getInt("Count"); } } @@ -1490,7 +1493,7 @@ void UniqueNodeListImp::scoreCompute() // <-- bNow: true, to force scoring for debugging. void UniqueNodeListImp::scoreNext (bool bNow) { - // WriteLog (lsTRACE, UniqueNodeList) << str(boost::format("scoreNext: mtpFetchUpdated=%s mtpScoreStart=%s mtpScoreUpdated=%s mtpScoreNext=%s") % mtpFetchUpdated % mtpScoreStart % mtpScoreUpdated % mtpScoreNext); + // JLOG (j_.trace) << str(boost::format("scoreNext: mtpFetchUpdated=%s mtpScoreStart=%s mtpScoreUpdated=%s mtpScoreNext=%s") % mtpFetchUpdated % mtpScoreStart % mtpScoreUpdated % mtpScoreNext); bool bCanScore = mtpScoreStart.is_not_a_date_time () // Not scoring. && !mtpFetchUpdated.is_not_a_date_time (); // Something to score. @@ -1506,7 +1509,7 @@ void UniqueNodeListImp::scoreNext (bool bNow) mtpScoreNext = boost::posix_time::second_clock::universal_time () // Past now too. + boost::posix_time::seconds (secondsFromNow); - // WriteLog (lsTRACE, UniqueNodeList) << str(boost::format("scoreNext: @%s") % mtpScoreNext); + // JLOG (j_.trace) << str(boost::format("scoreNext: @%s") % mtpScoreNext); m_scoreTimer.setExpiration (secondsFromNow); } } @@ -1528,12 +1531,12 @@ bool UniqueNodeListImp::responseFetch (std::string const& strDomain, const boost if (bGood) { - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << ": retrieved configuration"; } else { - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << ": unable to retrieve configuration: " << err.message (); } @@ -1543,11 +1546,11 @@ bool UniqueNodeListImp::responseFetch (std::string const& strDomain, const boost // std::string strSite; - if (bGood && !getSingleSection (secSite, SECTION_DOMAIN, strSite)) + if (bGood && !getSingleSection (secSite, SECTION_DOMAIN, strSite, j_)) { bGood = false; - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << ": " << SECTION_DOMAIN << "entry missing."; } @@ -1556,7 +1559,7 @@ bool UniqueNodeListImp::responseFetch (std::string const& strDomain, const boost { bGood = false; - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << ": " << SECTION_DOMAIN << " does not match " << strSite; } @@ -1565,12 +1568,12 @@ bool UniqueNodeListImp::responseFetch (std::string const& strDomain, const boost // std::string strNodePublicKey; - if (bGood && !getSingleSection (secSite, SECTION_PUBLIC_KEY, strNodePublicKey)) + if (bGood && !getSingleSection (secSite, SECTION_PUBLIC_KEY, strNodePublicKey, j_)) { // Bad [validation_public_key] IniFileSections. bGood = false; - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << ": " << SECTION_PUBLIC_KEY << " entry missing."; } @@ -1581,7 +1584,7 @@ bool UniqueNodeListImp::responseFetch (std::string const& strDomain, const boost // Bad public key. bGood = false; - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << ": " << SECTION_PUBLIC_KEY << " is not a public key: " << strNodePublicKey; } @@ -1604,7 +1607,7 @@ bool UniqueNodeListImp::responseFetch (std::string const& strDomain, const boost // XXX Only if no other refs to keep it arround, other wise we have an attack vector. sdCurrent.naPublicKey = naNodePublic; - // WriteLog (lsTRACE, UniqueNodeList) << boost::format("sdCurrent.naPublicKey: '%s'") % sdCurrent.naPublicKey.humanNodePublic(); + // JLOG (j_.trace) << boost::format("sdCurrent.naPublicKey: '%s'") % sdCurrent.naPublicKey.humanNodePublic(); sdCurrent.tpFetch = boost::posix_time::second_clock::universal_time (); sdCurrent.iSha256 = iSha256; @@ -1613,13 +1616,13 @@ bool UniqueNodeListImp::responseFetch (std::string const& strDomain, const boost if (bChangedB) { - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << ": processing new " << node_file_name_ << "."; processFile (strDomain, naNodePublic, secSite); } else { - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << ": no change in " << node_file_name_ << "."; fetchFinish (); } @@ -1672,7 +1675,7 @@ void UniqueNodeListImp::fetchNext() tpNext = ptFromSeconds (iNext); - WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("fetchNext: iNext=%s tpNext=%s tpNow=%s") % iNext % tpNext % tpNow); + JLOG (j_.trace) << str (boost::format ("fetchNext: iNext=%s tpNext=%s tpNow=%s") % iNext % tpNext % tpNow); if (soci::i_ok == ind) convert (b, strDomain); else @@ -1694,11 +1697,11 @@ void UniqueNodeListImp::fetchNext() if (strDomain.empty () || bFull) { - WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("fetchNext: strDomain=%s bFull=%d") % strDomain % bFull); + JLOG (j_.trace) << str (boost::format ("fetchNext: strDomain=%s bFull=%d") % strDomain % bFull); } else if (tpNext > tpNow) { - WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("fetchNext: set timer : strDomain=%s") % strDomain); + JLOG (j_.trace) << str (boost::format ("fetchNext: set timer : strDomain=%s") % strDomain); // Fetch needs to happen in the future. Set a timer to wake us. mtpFetchNext = tpNext; @@ -1712,7 +1715,7 @@ void UniqueNodeListImp::fetchNext() } else { - WriteLog (lsTRACE, UniqueNodeList) << str (boost::format ("fetchNext: fetch now: strDomain=%s tpNext=%s tpNow=%s") % strDomain % tpNext % tpNow); + JLOG (j_.trace) << str (boost::format ("fetchNext: fetch now: strDomain=%s tpNext=%s tpNow=%s") % strDomain % tpNext % tpNow); // Fetch needs to happen now. mtpFetchNext = boost::posix_time::ptime (boost::posix_time::not_a_date_time); @@ -1729,7 +1732,7 @@ void UniqueNodeListImp::fetchNext() setSeedDomains (sdCurrent, false); - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << " fetching " << node_file_name_ << "."; fetchProcess (strDomain); // Go get it. @@ -1770,7 +1773,7 @@ void UniqueNodeListImp::fetchFinish() // Get the ripple.txt and process it. void UniqueNodeListImp::fetchProcess (std::string strDomain) { - WriteLog (lsTRACE, UniqueNodeList) << strDomain + JLOG (j_.trace) << strDomain << ": fetching " << node_file_name_ << "."; std::deque deqSites; @@ -1791,7 +1794,8 @@ void UniqueNodeListImp::fetchProcess (std::string strDomain) boost::posix_time::seconds (NODE_FETCH_SECONDS), std::bind (&UniqueNodeListImp::responseFetch, this, strDomain, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); + std::placeholders::_3), + app_.logs ()); } // Process IniFileSections [validators_url]. @@ -1804,7 +1808,7 @@ void UniqueNodeListImp::getValidatorsUrl (RippleAddress const& naNodePublic, int iPort; std::string strPath; - if (getSingleSection (secSite, SECTION_VALIDATORS_URL, strValidatorsUrl) + if (getSingleSection (secSite, SECTION_VALIDATORS_URL, strValidatorsUrl, j_) && !strValidatorsUrl.empty () && parseUrl (strValidatorsUrl, strScheme, strDomain, iPort, strPath) && -1 == iPort @@ -1821,7 +1825,8 @@ void UniqueNodeListImp::getValidatorsUrl (RippleAddress const& naNodePublic, std::bind (&UniqueNodeListImp::responseValidators, this, strValidatorsUrl, naNodePublic, secSite, strDomain, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); + std::placeholders::_3), + app_.logs ()); } else { @@ -1841,7 +1846,7 @@ void UniqueNodeListImp::getIpsUrl (RippleAddress const& naNodePublic, IniFileSec int iPort; std::string strPath; - if (getSingleSection (secSite, SECTION_IPS_URL, strIpsUrl) + if (getSingleSection (secSite, SECTION_IPS_URL, strIpsUrl, j_) && !strIpsUrl.empty () && parseUrl (strIpsUrl, strScheme, strDomain, iPort, strPath) && -1 == iPort @@ -1857,7 +1862,8 @@ void UniqueNodeListImp::getIpsUrl (RippleAddress const& naNodePublic, IniFileSec boost::posix_time::seconds (NODE_FETCH_SECONDS), std::bind (&UniqueNodeListImp::responseIps, this, strDomain, naNodePublic, std::placeholders::_1, - std::placeholders::_2, std::placeholders::_3)); + std::placeholders::_2, std::placeholders::_3), + app_.logs ()); } else { @@ -1918,7 +1924,7 @@ void UniqueNodeListImp::processIps (std::string const& strSite, RippleAddress co { std::string strEscNodePublic = sqlEscape (naNodePublic.humanNodePublic ()); - WriteLog (lsDEBUG, UniqueNodeList) + JLOG (j_.debug) << str (boost::format ("Validator: '%s' processing %d ips.") % strSite % ( pmtVecStrIps ? pmtVecStrIps->size () : 0)); @@ -1956,7 +1962,7 @@ void UniqueNodeListImp::processIps (std::string const& strSite, RippleAddress co } else { - WriteLog (lsTRACE, UniqueNodeList) + JLOG (j_.trace) << str (boost::format ("Validator: '%s' [" SECTION_IPS "]: rejecting '%s'") % strSite % strReferral); } @@ -1988,7 +1994,7 @@ int UniqueNodeListImp::processValidators (std::string const& strSite, std::strin std::string strNodePublic = naNodePublic.isValid () ? naNodePublic.humanNodePublic () : strValidatorsSrc; int iValues = 0; - WriteLog (lsTRACE, UniqueNodeList) + JLOG (j_.trace) << str (boost::format ("Validator: '%s' : '%s' : processing %d validators.") % strSite % strValidatorsSrc @@ -2022,7 +2028,7 @@ int UniqueNodeListImp::processValidators (std::string const& strSite, std::strin if (!boost::regex_match (strReferral, smMatch, reReferral)) { - WriteLog (lsWARNING, UniqueNodeList) << str (boost::format ("Bad validator: syntax error: %s: %s") % strSite % strReferral); + JLOG (j_.warning) << str (boost::format ("Bad validator: syntax error: %s: %s") % strSite % strReferral); } else { @@ -2032,7 +2038,7 @@ int UniqueNodeListImp::processValidators (std::string const& strSite, std::strin if (naValidator.setSeedGeneric (strRefered)) { - WriteLog (lsWARNING, UniqueNodeList) << str (boost::format ("Bad validator: domain or public key required: %s %s") % strRefered % strComment); + JLOG (j_.warning) << str (boost::format ("Bad validator: domain or public key required: %s %s") % strRefered % strComment); } else if (naValidator.setNodePublic (strRefered)) { @@ -2040,7 +2046,7 @@ int UniqueNodeListImp::processValidators (std::string const& strSite, std::strin // XXX Schedule for CAS lookup. nodeAddPublic (naValidator, vsWhy, strComment); - WriteLog (lsINFO, UniqueNodeList) << str (boost::format ("Node Public: %s %s") % strRefered % strComment); + JLOG (j_.info) << str (boost::format ("Node Public: %s %s") % strRefered % strComment); if (naNodePublic.isValid ()) vstrValues.push_back (str (boost::format ("('%s',%d,'%s')") % strNodePublic % iValues % naValidator.humanNodePublic ())); @@ -2052,7 +2058,7 @@ int UniqueNodeListImp::processValidators (std::string const& strSite, std::strin // A domain: need to look it up. nodeAddDomain (strRefered, vsWhy, strComment); - WriteLog (lsINFO, UniqueNodeList) << str (boost::format ("Node Domain: %s %s") % strRefered % strComment); + JLOG (j_.info) << str (boost::format ("Node Domain: %s %s") % strRefered % strComment); if (naNodePublic.isValid ()) vstrValues.push_back (str (boost::format ("('%s',%d,%s)") % strNodePublic % iValues % sqlEscape (strRefered))); @@ -2103,7 +2109,7 @@ void UniqueNodeListImp::processFile (std::string const& strDomain, RippleAddress if ((pvCurrencies = getIniFileSection (secSite, SECTION_CURRENCIES)) && pvCurrencies->size ()) { // XXX Process currencies. - WriteLog (lsWARNING, UniqueNodeList) << "Ignoring currencies: not implemented."; + JLOG (j_.warning) << "Ignoring currencies: not implemented."; } getValidatorsUrl (naNodePublic, secSite); @@ -2201,7 +2207,7 @@ void UniqueNodeListImp::setSeedDomains (const seedDomain& sdSource, bool bNext) int iScan = iToSeconds (sdSource.tpScan); int iFetch = iToSeconds (sdSource.tpFetch); - // WriteLog (lsTRACE) << str(boost::format("setSeedDomains: iNext=%s tpNext=%s") % iNext % sdSource.tpNext); + // JLOG (lsTRACE) << str(boost::format("setSeedDomains: iNext=%s tpNext=%s") % iNext % sdSource.tpNext); std::string strSql = boost::str (boost::format ("REPLACE INTO SeedDomains (Domain,PublicKey,Source,Next,Scan,Fetch,Sha256,Comment) VALUES (%s, %s, %s, %d, %d, %d, '%s', %s);") % sqlEscape (sdSource.strDomain) @@ -2223,7 +2229,7 @@ void UniqueNodeListImp::setSeedDomains (const seedDomain& sdSource, bool bNext) catch (soci::soci_error& e) { // XXX Check result. - WriteLog (lsWARNING, UniqueNodeList) << "setSeedDomains: failed. Error: " << e.what(); + JLOG (j_.warning) << "setSeedDomains: failed. Error: " << e.what(); } if (bNext && (mtpFetchNext.is_not_a_date_time () || mtpFetchNext > sdSource.tpNext)) @@ -2310,7 +2316,7 @@ void UniqueNodeListImp::setSeedNodes (const seedNode& snSource, bool bNext) int iScan = iToSeconds (snSource.tpScan); int iFetch = iToSeconds (snSource.tpFetch); - // WriteLog (lsTRACE) << str(boost::format("setSeedNodes: iNext=%s tpNext=%s") % iNext % sdSource.tpNext); + // JLOG (lsTRACE) << str(boost::format("setSeedNodes: iNext=%s tpNext=%s") % iNext % sdSource.tpNext); assert (snSource.naPublicKey.isValid ()); @@ -2333,7 +2339,7 @@ void UniqueNodeListImp::setSeedNodes (const seedNode& snSource, bool bNext) } catch(soci::soci_error& e) { - WriteLog (lsTRACE, UniqueNodeList) << "setSeedNodes: failed. Error: " << e.what (); + JLOG (j_.trace) << "setSeedNodes: failed. Error: " << e.what (); } } @@ -2359,7 +2365,7 @@ bool UniqueNodeListImp::validatorsResponse (const boost::system::error_code& err if (!bReject) { - WriteLog (lsTRACE, UniqueNodeList) << + JLOG (j_.trace) << "Fetch '" << Config::Helpers::getValidatorsFileName () << "' complete."; @@ -2370,7 +2376,7 @@ bool UniqueNodeListImp::validatorsResponse (const boost::system::error_code& err } else { - WriteLog (lsWARNING, UniqueNodeList) << "Error: " << err.message (); + JLOG (j_.warning) << "Error: " << err.message (); } } return bReject; @@ -2399,7 +2405,7 @@ void UniqueNodeListImp::nodeProcess (std::string const& strSite, std::string con } else { - WriteLog (lsWARNING, UniqueNodeList) << boost::str (boost::format ("'%s' missing [" SECTION_VALIDATORS "].") + JLOG (j_.warning) << boost::str (boost::format ("'%s' missing [" SECTION_VALIDATORS "].") % app_.config().VALIDATORS_BASE); } } diff --git a/src/ripple/app/misc/Validations.cpp b/src/ripple/app/misc/Validations.cpp index 6e5041aead..894d10b820 100644 --- a/src/ripple/app/misc/Validations.cpp +++ b/src/ripple/app/misc/Validations.cpp @@ -51,6 +51,7 @@ private: ValidationVector mStaleValidations; bool mWriting; + beast::Journal j_; private: std::shared_ptr findCreateSet (uint256 const& ledgerHash) @@ -75,8 +76,9 @@ public: ValidationsImp (Application& app) : app_ (app) , mValidations ("Validations", 128, 600, stopwatch(), - app.logs().journal("TaggedCache")) + app.journal("TaggedCache")) , mWriting (false) + , j_ (app.journal ("Validations")) { mStaleValidations.reserve (512); } @@ -96,11 +98,11 @@ private: if ((now > (valClose - LEDGER_EARLY_INTERVAL)) && (now < (valClose + LEDGER_VAL_INTERVAL))) isCurrent = true; else - WriteLog (lsWARNING, Validations) << "Received stale validation now=" << now << ", close=" << valClose; + JLOG (j_.warning) << "Received stale validation now=" << now << ", close=" << valClose; if (!val->isTrusted ()) { - WriteLog (lsDEBUG, Validations) << "Node " << signer.humanNodePublic () << " not in UNL st=" << val->getSignTime () << + JLOG (j_.debug) << "Node " << signer.humanNodePublic () << " not in UNL st=" << val->getSignTime () << ", hash=" << val->getLedgerHash () << ", shash=" << val->getSigningHash () << " src=" << source; } @@ -141,7 +143,7 @@ private: } } - WriteLog (lsDEBUG, Validations) << "Val for " << hash << " from " << signer.humanNodePublic () + JLOG (j_.debug) << "Val for " << hash << " from " << signer.humanNodePublic () << " added " << (val->isTrusted () ? "trusted/" : "UNtrusted/") << (isCurrent ? "current" : "stale"); if (val->isTrusted () && isCurrent) @@ -195,7 +197,7 @@ private: isTrusted = false; else { - WriteLog (lsTRACE, Validations) << "VC: Untrusted due to time " << ledger; + JLOG (j_.trace) << "VC: Untrusted due to time " << ledger; } } @@ -206,7 +208,7 @@ private: } } - WriteLog (lsTRACE, Validations) << "VC: " << ledger << "t:" << trusted << " u:" << untrusted; + JLOG (j_.trace) << "VC: " << ledger << "t:" << trusted << " u:" << untrusted; } void getValidationTypes (uint256 const& ledger, int& full, int& partial) override @@ -229,7 +231,7 @@ private: } } - WriteLog (lsTRACE, Validations) << "VC: " << ledger << "f:" << full << " p:" << partial; + JLOG (j_.trace) << "VC: " << ledger << "f:" << full << " p:" << partial; } @@ -377,7 +379,7 @@ private: (valPriorLedger && (it->second->getLedgerHash () == priorLedger)))) { countPreferred = true; - WriteLog (lsTRACE, Validations) << "Counting for " << currentLedger << " not " << it->second->getLedgerHash (); + JLOG (j_.trace) << "Counting for " << currentLedger << " not " << it->second->getLedgerHash (); } ValidationCounter& p = countPreferred ? ret[currentLedger] : ret[it->second->getLedgerHash ()]; @@ -410,7 +412,7 @@ private: { bool anyNew = false; - WriteLog (lsINFO, Validations) << "Flushing validations"; + JLOG (j_.info) << "Flushing validations"; ScopedLockType sl (mLock); for (auto& it: mCurrentValidations) { @@ -430,7 +432,7 @@ private: std::this_thread::sleep_for (std::chrono::milliseconds (100)); } - WriteLog (lsDEBUG, Validations) << "Validations flushed"; + JLOG (j_.debug) << "Validations flushed"; } void condWrite () diff --git a/src/ripple/app/misc/impl/AccountTxPaging.cpp b/src/ripple/app/misc/impl/AccountTxPaging.cpp index acc7433c0a..fbe2550073 100644 --- a/src/ripple/app/misc/impl/AccountTxPaging.cpp +++ b/src/ripple/app/misc/impl/AccountTxPaging.cpp @@ -50,7 +50,7 @@ convertBlobsToTxResult ( tr->setLedger (ledger_index); auto metaset = std::make_shared ( - tr->getID (), tr->getLedger (), rawMeta); + tr->getID (), tr->getLedger (), rawMeta, app.journal ("TxMeta")); to.emplace_back(std::move(tr), metaset); }; diff --git a/src/ripple/app/paths/PathRequest.cpp b/src/ripple/app/paths/PathRequest.cpp index 553ab530ba..05efa084e4 100644 --- a/src/ripple/app/paths/PathRequest.cpp +++ b/src/ripple/app/paths/PathRequest.cpp @@ -485,7 +485,8 @@ PathRequest::findPaths ( *sandbox, saMaxAmount, convert_all_ ? STAmount(saDstAmount.issue(), STAmount::cMaxValue, STAmount::cMaxOffset) : saDstAmount, - *raDstAccount, *raSrcAccount, *result, &rcInput); + *raDstAccount, *raSrcAccount, *result, + app_.logs (), &rcInput); if (! convert_all_ && ! fullLiquidityPath.empty() && @@ -498,7 +499,7 @@ PathRequest::findPaths ( rc = path::RippleCalc::rippleCalculate( *sandbox, saMaxAmount, saDstAmount, - *raDstAccount, *raSrcAccount, *result); + *raDstAccount, *raSrcAccount, *result, app_.logs ()); if (rc.result() != tesSUCCESS) { m_journal.warning << iIdentifier diff --git a/src/ripple/app/paths/PathState.cpp b/src/ripple/app/paths/PathState.cpp index 5792bcd144..b9142ea8a5 100644 --- a/src/ripple/app/paths/PathState.cpp +++ b/src/ripple/app/paths/PathState.cpp @@ -108,7 +108,7 @@ TER PathState::pushImpliedNodes ( { TER resultCode = tesSUCCESS; - WriteLog (lsTRACE, RippleCalc) << "pushImpliedNodes>" << + JLOG (j_.trace) << "pushImpliedNodes>" << " " << account << " " << currency << " " << issuer; @@ -147,7 +147,7 @@ TER PathState::pushImpliedNodes ( STPathElement::typeAll, issuer, currency, issuer); } - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "pushImpliedNodes< : " << transToken (resultCode); return resultCode; @@ -185,7 +185,7 @@ TER PathState::pushNode ( TER resultCode = tesSUCCESS; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "pushNode> " << iType << ": " << (hasAccount ? to_string(account) : std::string("-")) << " " << (hasCurrency ? to_string(currency) : std::string("-")) << "/" @@ -201,18 +201,18 @@ TER PathState::pushNode ( if (iType & ~STPathElement::typeAll) { // Of course, this could never happen. - WriteLog (lsDEBUG, RippleCalc) << "pushNode: bad bits."; + JLOG (j_.debug) << "pushNode: bad bits."; resultCode = temBAD_PATH; } else if (hasIssuer && isXRP (node.issue_)) { - WriteLog (lsDEBUG, RippleCalc) << "pushNode: issuer specified for XRP."; + JLOG (j_.debug) << "pushNode: issuer specified for XRP."; resultCode = temBAD_PATH; } else if (hasIssuer && !issuer) { - WriteLog (lsDEBUG, RippleCalc) << "pushNode: specified bad issuer."; + JLOG (j_.debug) << "pushNode: specified bad issuer."; resultCode = temBAD_PATH; } @@ -220,7 +220,7 @@ TER PathState::pushNode ( { // You can't default everything to the previous node as you would make // no progress. - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "pushNode: offer must specify at least currency or issuer."; resultCode = temBAD_PATH; } @@ -244,14 +244,14 @@ TER PathState::pushNode ( } else if (!account) { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "pushNode: specified bad account."; resultCode = temBAD_PATH; } else { // Add required intermediate nodes to deliver to current account. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "pushNode: imply for account."; resultCode = pushImpliedNodes ( @@ -274,18 +274,18 @@ TER PathState::pushNode ( // specific currency. if (!sleRippleState) { - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "pushNode: No credit line between " << backNode.account_ << " and " << node.account_ << " for " << node.issue_.currency << "." ; - WriteLog (lsTRACE, RippleCalc) << getJson (); + JLOG (j_.trace) << getJson (); resultCode = terNO_LINE; } else { - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "pushNode: Credit line found between " << backNode.account_ << " and " << node.account_ << " for " << node.issue_.currency << "." ; @@ -297,7 +297,7 @@ TER PathState::pushNode ( if (!sleBck) { - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "pushNode: delay: can't receive IOUs from " << "non-existent issuer: " << backNode.account_; @@ -308,7 +308,7 @@ TER PathState::pushNode ( (bHigh ? lsfHighAuth : lsfLowAuth)) && sleRippleState->getFieldAmount(sfBalance) == zero) { - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "pushNode: delay: can't receive IOUs from " << "issuer without auth."; @@ -330,7 +330,7 @@ TER PathState::pushNode ( node.issue_.currency); if (-saOwed >= saLimit) { - WriteLog (lsDEBUG, RippleCalc) << + JLOG (j_.debug) << "pushNode: dry:" << " saOwed=" << saOwed << " saLimit=" << saLimit; @@ -367,19 +367,19 @@ TER PathState::pushNode ( if (!isConsistent (node.issue_)) { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "pushNode: currency is inconsistent with issuer."; resultCode = temBAD_PATH; } else if (backNode.issue_ == node.issue_) { - WriteLog (lsDEBUG, RippleCalc) << + JLOG (j_.debug) << "pushNode: bad path: offer to same currency and issuer"; resultCode = temBAD_PATH; } else { - WriteLog (lsTRACE, RippleCalc) << "pushNode: imply for offer."; + JLOG (j_.trace) << "pushNode: imply for offer."; // Insert intermediary issuer account if needed. resultCode = pushImpliedNodes ( @@ -392,7 +392,7 @@ TER PathState::pushNode ( nodes_.push_back (node); } - WriteLog (lsTRACE, RippleCalc) << "pushNode< : " << transToken (resultCode); + JLOG (j_.trace) << "pushNode< : " << transToken (resultCode); return resultCode; } @@ -428,7 +428,7 @@ TER PathState::expandPath ( = isXRP(uMaxCurrencyID) ? xrpAccount() : uSenderID; // Sender is always issuer for non-XRP. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "expandPath> " << spSourcePath.getJson (0); terStatus = tesSUCCESS; @@ -437,7 +437,7 @@ TER PathState::expandPath ( if ((isXRP (uMaxCurrencyID) && !isXRP (uMaxIssuerID)) || (isXRP (currencyOutID) && !isXRP (issuerOutID))) { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "expandPath> issuer with XRP"; terStatus = temBAD_PATH; } @@ -458,7 +458,7 @@ TER PathState::expandPath ( uSenderIssuerID); } - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "expandPath: pushed:" << " account=" << uSenderID << " currency=" << uMaxCurrencyID @@ -487,7 +487,7 @@ TER PathState::expandPath ( : AccountID(issuerOutID) // Use implied node. : xrpAccount(); - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "expandPath: implied check:" << " uMaxIssuerID=" << uMaxIssuerID << " uSenderIssuerID=" << uSenderIssuerID @@ -503,7 +503,7 @@ TER PathState::expandPath ( || uMaxIssuerID != nextAccountID) // Next is not implied issuer { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "expandPath: sender implied:" << " account=" << uMaxIssuerID << " currency=" << uMaxCurrencyID @@ -525,7 +525,7 @@ TER PathState::expandPath ( { if (terStatus == tesSUCCESS) { - WriteLog (lsTRACE, RippleCalc) << "expandPath: element in path"; + JLOG (j_.trace) << "expandPath: element in path"; terStatus = pushNode ( speElement.getNodeType (), speElement.getAccountID (), speElement.getCurrency (), speElement.getIssuerID ()); @@ -544,7 +544,7 @@ TER PathState::expandPath ( || backNode.account_ != issuerOutID) // Need implied issuer { // Add implied account. - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "expandPath: receiver implied:" << " account=" << issuerOutID << " currency=" << currencyOutID @@ -587,7 +587,7 @@ TER PathState::expandPath ( if (!umForward.insert ({accountIssue, index++}).second) { // Failed to insert. Have a loop. - WriteLog (lsDEBUG, RippleCalc) << + JLOG (j_.debug) << "expandPath: loop detected: " << getJson (); terStatus = temBAD_PATH_LOOP; @@ -596,7 +596,7 @@ TER PathState::expandPath ( } } - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "expandPath:" << " in=" << uMaxCurrencyID << "/" << uMaxIssuerID @@ -692,7 +692,7 @@ TER PathState::checkNoRipple ( sleOut->getFieldU32 (sfFlags) & ((secondAccount > thirdAccount) ? lsfHighNoRipple : lsfLowNoRipple)) { - WriteLog (lsINFO, RippleCalc) + JLOG (j_.info) << "Path violates noRipple constraint between " << firstAccount << ", " << secondAccount << " and " diff --git a/src/ripple/app/paths/PathState.h b/src/ripple/app/paths/PathState.h index 952f07aa8d..72f4fdc5f6 100644 --- a/src/ripple/app/paths/PathState.h +++ b/src/ripple/app/paths/PathState.h @@ -37,11 +37,13 @@ class PathState : public CountedObject PathState (PaymentSandbox const& parent, STAmount const& saSend, - STAmount const& saSendMax) + STAmount const& saSendMax, + beast::Journal j) : mIndex (0) , uQuality (0) , saInReq (saSendMax) , saOutReq (saSend) + , j_ (j) { view_.emplace(&parent); } @@ -166,6 +168,8 @@ private: // First time working in reverse a funding source was used. // Source may only be used there if not mentioned by an account. AccountIssueToNodeIndex umReverse; + + beast::Journal j_; }; } // ripple diff --git a/src/ripple/app/paths/Pathfinder.cpp b/src/ripple/app/paths/Pathfinder.cpp index 27dd37bc8a..c483a90542 100644 --- a/src/ripple/app/paths/Pathfinder.cpp +++ b/src/ripple/app/paths/Pathfinder.cpp @@ -164,7 +164,8 @@ Pathfinder::Pathfinder ( STAmount(mDstAmount.issue(), STAmount::cMaxValue, STAmount::cMaxOffset)), mLedger (cache->getLedger ()), mRLCache (cache), - app_ (app) + app_ (app), + j_ (app.journal ("Pathfinder")) { assert (! uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.get())); } @@ -178,7 +179,7 @@ bool Pathfinder::findPaths (int searchLevel) if (mDstAmount == zero) { // No need to send zero money. - WriteLog (lsDEBUG, Pathfinder) << "Destination amount was zero."; + JLOG (j_.debug) << "Destination amount was zero."; mLedger.reset (); return false; @@ -191,7 +192,7 @@ bool Pathfinder::findPaths (int searchLevel) mSrcCurrency == mDstAmount.getCurrency ()) { // No need to send to same account with same currency. - WriteLog (lsDEBUG, Pathfinder) << "Tried to send to same issuer"; + JLOG (j_.debug) << "Tried to send to same issuer"; mLedger.reset (); return false; } @@ -214,7 +215,7 @@ bool Pathfinder::findPaths (int searchLevel) mSource = STPathElement (account, mSrcCurrency, issuer); auto issuerString = mSrcIssuer ? to_string (*mSrcIssuer) : std::string ("none"); - WriteLog (lsTRACE, Pathfinder) + JLOG (j_.trace) << "findPaths>" << " mSrcAccount=" << mSrcAccount << " mDstAccount=" << mDstAccount @@ -224,7 +225,7 @@ bool Pathfinder::findPaths (int searchLevel) if (!mLedger) { - WriteLog (lsDEBUG, Pathfinder) << "findPaths< no ledger"; + JLOG (j_.debug) << "findPaths< no ledger"; return false; } @@ -234,14 +235,14 @@ bool Pathfinder::findPaths (int searchLevel) if (! mLedger->exists (keylet::account(mSrcAccount))) { // We can't even start without a source account. - WriteLog (lsDEBUG, Pathfinder) << "invalid source account"; + JLOG (j_.debug) << "invalid source account"; return false; } if ((mEffectiveDst != mDstAccount) && ! mLedger->exists (keylet::account(mEffectiveDst))) { - WriteLog (lsDEBUG, Pathfinder) + JLOG (j_.debug) << "Non-existent gateway"; return false; } @@ -252,7 +253,7 @@ bool Pathfinder::findPaths (int searchLevel) // account. if (!bDstXrp) { - WriteLog (lsDEBUG, Pathfinder) + JLOG (j_.debug) << "New account not being funded in XRP "; return false; } @@ -260,7 +261,7 @@ bool Pathfinder::findPaths (int searchLevel) auto const reserve = STAmount (mLedger->fees().accountReserve (0)); if (mDstAmount < reserve) { - WriteLog (lsDEBUG, Pathfinder) + JLOG (j_.debug) << "New account not getting enough funding: " << mDstAmount << " < " << reserve; return false; @@ -273,31 +274,31 @@ bool Pathfinder::findPaths (int searchLevel) if (bSrcXrp && bDstXrp) { // XRP -> XRP - WriteLog (lsDEBUG, Pathfinder) << "XRP to XRP payment"; + JLOG (j_.debug) << "XRP to XRP payment"; paymentType = pt_XRP_to_XRP; } else if (bSrcXrp) { // XRP -> non-XRP - WriteLog (lsDEBUG, Pathfinder) << "XRP to non-XRP payment"; + JLOG (j_.debug) << "XRP to non-XRP payment"; paymentType = pt_XRP_to_nonXRP; } else if (bDstXrp) { // non-XRP -> XRP - WriteLog (lsDEBUG, Pathfinder) << "non-XRP to XRP payment"; + JLOG (j_.debug) << "non-XRP to XRP payment"; paymentType = pt_nonXRP_to_XRP; } else if (mSrcCurrency == mDstAmount.getCurrency ()) { // non-XRP -> non-XRP - Same currency - WriteLog (lsDEBUG, Pathfinder) << "non-XRP to non-XRP - same currency"; + JLOG (j_.debug) << "non-XRP to non-XRP - same currency"; paymentType = pt_nonXRP_to_same; } else { // non-XRP to non-XRP - Different currency - WriteLog (lsDEBUG, Pathfinder) << "non-XRP to non-XRP - cross currency"; + JLOG (j_.debug) << "non-XRP to non-XRP - cross currency"; paymentType = pt_nonXRP_to_nonXRP; } @@ -316,7 +317,7 @@ bool Pathfinder::findPaths (int searchLevel) } } - WriteLog (lsDEBUG, Pathfinder) + JLOG (j_.debug) << mCompletePaths.size () << " complete paths found"; // Even if we find no paths, default paths may work, and we don't check them @@ -352,6 +353,7 @@ TER Pathfinder::getPathLiquidity ( mDstAccount, mSrcAccount, pathSet, + app_.logs(), &rcInput); // If we can't get even the minimum liquidity requested, we're done. if (rc.result () != tesSUCCESS) @@ -371,6 +373,7 @@ TER Pathfinder::getPathLiquidity ( mDstAccount, mSrcAccount, pathSet, + app_.logs (), &rcInput); // If we found further liquidity, add it into the result. @@ -382,7 +385,7 @@ TER Pathfinder::getPathLiquidity ( } catch (std::exception const& e) { - WriteLog (lsINFO, Pathfinder) << + JLOG (j_.info) << "checkpath: exception (" << e.what() << ") " << path.getJson (0); return tefEXCEPTION; @@ -421,23 +424,24 @@ void Pathfinder::computePathRanks (int maxPaths) mDstAccount, mSrcAccount, STPathSet(), + app_.logs (), &rcInput); if (rc.result () == tesSUCCESS) { - WriteLog (lsDEBUG, Pathfinder) + JLOG (j_.debug) << "Default path contributes: " << rc.actualAmountIn; mRemainingAmount -= rc.actualAmountOut; } else { - WriteLog (lsDEBUG, Pathfinder) + JLOG (j_.debug) << "Default path fails: " << transToken (rc.result ()); } } catch (...) { - WriteLog (lsDEBUG, Pathfinder) << "Default path causes exception"; + JLOG (j_.debug) << "Default path causes exception"; } rankPaths (maxPaths, mCompletePaths, mPathRanks); @@ -509,14 +513,14 @@ void Pathfinder::rankPaths ( currentPath, saMinDstAmount, liquidity, uQuality); if (resultCode != tesSUCCESS) { - WriteLog (lsDEBUG, Pathfinder) << + JLOG (j_.debug) << "findPaths: dropping : " << transToken (resultCode) << ": " << currentPath.getJson (0); } else { - WriteLog (lsDEBUG, Pathfinder) << + JLOG (j_.debug) << "findPaths: quality: " << uQuality << ": " << currentPath.getJson (0); @@ -558,7 +562,7 @@ Pathfinder::getBestPaths ( STPathSet const& extraPaths, AccountID const& srcIssuer) { - WriteLog (lsDEBUG, Pathfinder) << "findPaths: " << + JLOG (j_.debug) << "findPaths: " << mCompletePaths.size() << " paths and " << extraPaths.size () << " extras"; @@ -655,12 +659,12 @@ Pathfinder::getBestPaths ( { // We found an extra path that can move the whole amount. fullLiquidityPath = (startsWithIssuer ? removeIssuer (path) : path); - WriteLog (lsDEBUG, Pathfinder) << + JLOG (j_.debug) << "Found extra full path: " << fullLiquidityPath.getJson (0); } else { - WriteLog (lsDEBUG, Pathfinder) << + JLOG (j_.debug) << "Skipping a non-filling path: " << path.getJson (0); } } @@ -668,12 +672,12 @@ Pathfinder::getBestPaths ( if (remaining > zero) { assert (fullLiquidityPath.empty ()); - WriteLog (lsINFO, Pathfinder) << + JLOG (j_.info) << "Paths could not send " << remaining << " of " << mDstAmount; } else { - WriteLog (lsDEBUG, Pathfinder) << + JLOG (j_.debug) << "findPaths: RESULTS: " << bestPaths.getJson (0); } return bestPaths; @@ -760,7 +764,7 @@ void Pathfinder::addLinks ( STPathSet& incompletePaths, // The set of partial paths we add to int addFlags) { - WriteLog (lsDEBUG, Pathfinder) + JLOG (j_.debug) << "addLink< on " << currentPaths.size () << " source(s), flags=" << addFlags; for (auto const& path: currentPaths) @@ -786,7 +790,7 @@ STPathSet& Pathfinder::addPathsForType (PathType const& pathType) STPathSet const& parentPaths = addPathsForType (parentPathType); STPathSet& pathsOut = mPaths[pathType]; - WriteLog (lsDEBUG, Pathfinder) + JLOG (j_.debug) << "getPaths< adding onto '" << pathTypeToString (parentPathType) << "' to get '" << pathTypeToString (pathType) << "'"; @@ -830,7 +834,7 @@ STPathSet& Pathfinder::addPathsForType (PathType const& pathType) CondLog (mCompletePaths.size () != initialSize, lsDEBUG, Pathfinder) << (mCompletePaths.size () - initialSize) << " complete paths added"; - WriteLog (lsDEBUG, Pathfinder) + JLOG (j_.debug) << "getPaths> " << pathsOut.size () << " partial paths found"; return pathsOut; } @@ -900,9 +904,9 @@ void Pathfinder::addLink ( // rather than the ultimate destination? bool const hasEffectiveDestination = mEffectiveDst != mDstAccount; - WriteLog (lsTRACE, Pathfinder) << "addLink< flags=" + JLOG (j_.trace) << "addLink< flags=" << addFlags << " onXRP=" << bOnXRP; - WriteLog (lsTRACE, Pathfinder) << currentPath.getJson (0); + JLOG (j_.trace) << currentPath.getJson (0); if (addFlags & afADD_ACCOUNTS) { @@ -911,7 +915,7 @@ void Pathfinder::addLink ( { if (mDstAmount.native () && !currentPath.empty ()) { // non-default path to XRP destination - WriteLog (lsTRACE, Pathfinder) + JLOG (j_.trace) << "complete path found ax: " << currentPath.getJson(0); addUniquePath (mCompletePaths, currentPath); } @@ -942,7 +946,7 @@ void Pathfinder::addLink ( auto* rs = dynamic_cast (item.get ()); if (!rs) { - WriteLog (lsERROR, Pathfinder) + JLOG (j_.error) << "Couldn't decipher RippleState"; continue; } @@ -984,7 +988,7 @@ void Pathfinder::addLink ( // this is a complete path if (!currentPath.empty ()) { - WriteLog (lsTRACE, Pathfinder) + JLOG (j_.trace) << "complete path found ae: " << currentPath.getJson (0); addUniquePath @@ -1048,7 +1052,7 @@ void Pathfinder::addLink ( } else { - WriteLog (lsWARNING, Pathfinder) + JLOG (j_.warning) << "Path ends on non-existent issuer"; } } @@ -1075,7 +1079,7 @@ void Pathfinder::addLink ( bool bDestOnly = (addFlags & afOB_LAST) != 0; auto books = app_.getOrderBookDB ().getBooksByTakerPays( {uEndCurrency, uEndIssuer}); - WriteLog (lsTRACE, Pathfinder) + JLOG (j_.trace) << books.size () << " books found from this currency/issuer"; for (auto const& book : books) @@ -1104,7 +1108,7 @@ void Pathfinder::addLink ( { // destination is XRP, add account and path is // complete - WriteLog (lsTRACE, Pathfinder) + JLOG (j_.trace) << "complete path found bx: " << currentPath.getJson(0); addUniquePath (mCompletePaths, newPath); @@ -1147,7 +1151,7 @@ void Pathfinder::addLink ( else if (book->getIssuerOut() == mEffectiveDst && book->getCurrencyOut() == mDstAmount.getCurrency()) { // with the destination account, this path is complete - WriteLog (lsTRACE, Pathfinder) + JLOG (j_.trace) << "complete path found ba: " << currentPath.getJson(0); addUniquePath (mCompletePaths, newPath); diff --git a/src/ripple/app/paths/Pathfinder.h b/src/ripple/app/paths/Pathfinder.h index 7fc5de1f61..469dc27962 100644 --- a/src/ripple/app/paths/Pathfinder.h +++ b/src/ripple/app/paths/Pathfinder.h @@ -192,6 +192,7 @@ private: hash_map mPathsOutCountMap; Application& app_; + beast::Journal j_; // Add ripple paths static std::uint32_t const afADD_ACCOUNTS = 0x001; diff --git a/src/ripple/app/paths/RippleCalc.cpp b/src/ripple/app/paths/RippleCalc.cpp index 4d81027c2a..a6dc2ce89e 100644 --- a/src/ripple/app/paths/RippleCalc.cpp +++ b/src/ripple/app/paths/RippleCalc.cpp @@ -32,11 +32,11 @@ namespace { static TER deleteOffers (ApplyView& view, - OfferSet const& offers) + OfferSet const& offers, beast::Journal j) { for (auto& e: offers) if (TER r = offerDelete (view, - view.peek(keylet::offer(e)))) + view.peek(keylet::offer(e)), j)) return r; return tesSUCCESS; } @@ -67,6 +67,7 @@ RippleCalc::Output RippleCalc::rippleCalculate ( // A set of paths that are included in the transaction that we'll // explore for liquidity. STPathSet const& spsPaths, + Logs& l, Input const* const pInputs) { RippleCalc rc ( @@ -75,7 +76,8 @@ RippleCalc::Output RippleCalc::rippleCalculate ( saDstAmountReq, uDstAccountID, uSrcAccountID, - spsPaths); + spsPaths, + l); if (pInputs != nullptr) { rc.inputFlags = *pInputs; @@ -94,7 +96,7 @@ RippleCalc::Output RippleCalc::rippleCalculate ( bool RippleCalc::addPathState(STPath const& path, TER& resultCode) { auto pathState = std::make_shared ( - view, saDstAmountReq_, saMaxAmountReq_); + view, saDstAmountReq_, saMaxAmountReq_, j_); if (!pathState) { @@ -115,7 +117,7 @@ bool RippleCalc::addPathState(STPath const& path, TER& resultCode) pathState->setIndex (pathStateList_.size ()); - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "rippleCalc: Build direct:" << " status: " << transToken (pathState->status()); @@ -145,7 +147,7 @@ bool RippleCalc::addPathState(STPath const& path, TER& resultCode) // <-- TER: Only returns tepPATH_PARTIAL if partialPaymentAllowed. TER RippleCalc::rippleCalculate () { - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "rippleCalc>" << " saMaxAmountReq_:" << saMaxAmountReq_ << " saDstAmountReq_:" << saDstAmountReq_; @@ -164,7 +166,7 @@ TER RippleCalc::rippleCalculate () } else if (spsPaths_.empty ()) { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "rippleCalc: Invalid transaction:" << "No paths and direct ripple not allowed."; @@ -175,7 +177,7 @@ TER RippleCalc::rippleCalculate () // nodes. // XXX Might also make a XRP bridge by default. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "rippleCalc: Paths in set: " << spsPaths_.size (); // Now expand the path state. @@ -224,11 +226,11 @@ TER RippleCalc::rippleCalculate () pathState->reset (actualAmountIn_, actualAmountOut_); // Error if done, output met. - PathCursor pc(*this, *pathState, multiQuality); + PathCursor pc(*this, *pathState, multiQuality, j_); pc.nextIncrement (); // Compute increment. - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "rippleCalc: AFTER:" << " mIndex=" << pathState->index() << " uQuality=" << pathState->quality() @@ -245,7 +247,7 @@ TER RippleCalc::rippleCalculate () // Path is not dry, but moved no funds // This should never happen. Consider the path dry - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "rippelCalc: Non-dry path moves no funds"; assert (false); @@ -275,7 +277,7 @@ TER RippleCalc::rippleCalculate () *pathStateList_[iBest], *pathState))) // Current is better than set. { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "rippleCalc: better:" << " mIndex=" << pathState->index() << " uQuality=" << pathState->quality() @@ -293,14 +295,14 @@ TER RippleCalc::rippleCalculate () ++iPass; if (ShouldLog (lsDEBUG, RippleCalc)) { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "rippleCalc: Summary:" << " Pass: " << iPass << " Dry: " << iDry << " Paths: " << pathStateList_.size (); for (auto pathState: pathStateList_) { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "rippleCalc: " << "Summary: " << pathState->index() << " rate: " @@ -315,7 +317,7 @@ TER RippleCalc::rippleCalculate () // Apply best path. auto pathState = pathStateList_[iBest]; - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "rippleCalc: best:" << " uQuality=" << amountFromRate (pathState->quality()) @@ -349,7 +351,7 @@ TER RippleCalc::rippleCalculate () } else if (actualAmountOut_ > saDstAmountReq_) { - WriteLog (lsFATAL, RippleCalc) + JLOG (j_.fatal) << "rippleCalc: TOO MUCH:" << " actualAmountOut_:" << actualAmountOut_ << " saDstAmountReq_:" << saDstAmountReq_; @@ -371,7 +373,7 @@ TER RippleCalc::rippleCalculate () { // This payment is taking too many passes - WriteLog (lsERROR, RippleCalc) + JLOG (j_.error) << "rippleCalc: pass limit"; resultCode = telFAILED_PROCESSING; @@ -412,9 +414,10 @@ TER RippleCalc::rippleCalculate () if (resultCode == tesSUCCESS) { - resultCode = deleteOffers(view, unfundedOffersFromBestPaths); + auto viewJ = logs_.journal ("View"); + resultCode = deleteOffers(view, unfundedOffersFromBestPaths, viewJ); if (resultCode == tesSUCCESS) - resultCode = deleteOffers(view, permanentlyUnfundedOffers_); + resultCode = deleteOffers(view, permanentlyUnfundedOffers_, viewJ); } // If isOpenLedger, then ledger is not final, can vote no. diff --git a/src/ripple/app/paths/RippleCalc.h b/src/ripple/app/paths/RippleCalc.h index 4fe2d98c81..b1fc42211c 100644 --- a/src/ripple/app/paths/RippleCalc.h +++ b/src/ripple/app/paths/RippleCalc.h @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -98,6 +99,7 @@ public: // A set of paths that are included in the transaction that we'll // explore for liquidity. STPathSet const& spsPaths, + Logs& l, Input const* const pInputs = nullptr); // The view we are currently working on @@ -114,6 +116,8 @@ public: // Map of currency, issuer to node index. AccountIssueToNodeIndex mumSource_; + beast::Journal j_; + Logs& logs_; private: RippleCalc ( @@ -123,8 +127,11 @@ private: AccountID const& uDstAccountID, AccountID const& uSrcAccountID, - STPathSet const& spsPaths) + STPathSet const& spsPaths, + Logs& l) : view (view_), + j_ (l.journal ("RippleCalc")), + logs_ (l), saDstAmountReq_(saDstAmountReq), saMaxAmountReq_(saMaxAmountReq), uDstAccountID_(uDstAccountID), diff --git a/src/ripple/app/paths/cursor/AdvanceNode.cpp b/src/ripple/app/paths/cursor/AdvanceNode.cpp index 24f72a0626..6c7554ef26 100644 --- a/src/ripple/app/paths/cursor/AdvanceNode.cpp +++ b/src/ripple/app/paths/cursor/AdvanceNode.cpp @@ -33,7 +33,7 @@ TER PathCursor::advanceNode (STAmount const& amount, bool reverse) const return advanceNode (reverse); // Otherwise, use a new PathCursor with the new multiQuality_. - PathCursor withMultiQuality {rippleCalc_, pathState_, multi, nodeIndex_}; + PathCursor withMultiQuality {rippleCalc_, pathState_, multi, j_, nodeIndex_}; return withMultiQuality.advanceNode (reverse); } @@ -46,11 +46,12 @@ TER PathCursor::advanceNode (bool const bReverse) const // Taker is the active party against an offer in the ledger - the entity // that is taking advantage of an offer in the order book. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: TakerPays:" << node().saTakerPays << " TakerGets:" << node().saTakerGets; int loopCount = 0; + auto viewJ = rippleCalc_.logs_.journal ("View"); do { @@ -62,7 +63,7 @@ TER PathCursor::advanceNode (bool const bReverse) const // if (++loopCount > NODE_ADVANCE_MAX_LOOPS) { - WriteLog (lsWARNING, RippleCalc) << "Loop count exceeded"; + JLOG (j_.warning) << "Loop count exceeded"; return tefEXCEPTION; } @@ -77,13 +78,13 @@ TER PathCursor::advanceNode (bool const bReverse) const { // We didn't run off the end of this order book and found // another quality directory. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: Quality advance: node.directory.current=" << node().directory.current; } else if (bReverse) { - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: No more offers."; node().offerIndex_ = 0; @@ -93,7 +94,7 @@ TER PathCursor::advanceNode (bool const bReverse) const { // No more offers. Should be done rather than fall off end of // book. - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "advanceNode: Unreachable: " << "Fell off end of order book."; // FIXME: why? @@ -111,7 +112,7 @@ TER PathCursor::advanceNode (bool const bReverse) const node().uEntry = 0; node().bEntryAdvance = true; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: directory dirty: node.saOfrRate=" << node().saOfrRate; } @@ -131,23 +132,23 @@ TER PathCursor::advanceNode (bool const bReverse) const node().saOfferFunds = accountFunds(view(), node().offerOwnerAccount_, node().saTakerGets, - fhZERO_IF_FROZEN); + fhZERO_IF_FROZEN, viewJ); node().bFundsDirty = false; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: funds dirty: node().saOfrRate=" << node().saOfrRate; } else { - WriteLog (lsTRACE, RippleCalc) << "advanceNode: as is"; + JLOG (j_.trace) << "advanceNode: as is"; } } else if (!dirNext (view(), node().directory.current, node().directory.ledgerEntry, node().uEntry, - node().offerIndex_)) + node().offerIndex_, viewJ)) // This is the only place that offerIndex_ changes. { // Failed to find an entry in directory. @@ -156,7 +157,7 @@ TER PathCursor::advanceNode (bool const bReverse) const { // We are allowed to process multiple qualities if this is the // only path. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: next quality"; node().directory.advanceNeeded = true; // Process next quality. } @@ -166,7 +167,7 @@ TER PathCursor::advanceNode (bool const bReverse) const // going forwards - this should be impossible! // TODO(tom): these warnings occur in production! They // shouldn't. - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "advanceNode: unreachable: ran out of offers"; return telFAILED_PROCESSING; } @@ -186,7 +187,7 @@ TER PathCursor::advanceNode (bool const bReverse) const { // Corrupt directory that points to an entry that doesn't exist. // This has happened in production. - WriteLog (lsWARNING, RippleCalc) << + JLOG (j_.warning) << "Missing offer in directory"; node().bEntryAdvance = true; } @@ -202,7 +203,7 @@ TER PathCursor::advanceNode (bool const bReverse) const AccountIssue const accountIssue ( node().offerOwnerAccount_, node().issue_); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: offerOwnerAccount_=" << to_string (node().offerOwnerAccount_) << " node.saTakerPays=" << node().saTakerPays @@ -214,7 +215,7 @@ TER PathCursor::advanceNode (bool const bReverse) const view().parentCloseTime())) { // Offer is expired. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: expired offer"; rippleCalc_.permanentlyUnfundedOffers_.insert( node().offerIndex_); @@ -230,7 +231,7 @@ TER PathCursor::advanceNode (bool const bReverse) const { // Past internal error, offer had bad amounts. // This has occurred in production. - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "advanceNode: PAST INTERNAL ERROR" << " REVERSE: OFFER NON-POSITIVE:" << " node.saTakerPays=" << node().saTakerPays @@ -246,7 +247,7 @@ TER PathCursor::advanceNode (bool const bReverse) const // Past internal error, offer was found failed to place // this in permanentlyUnfundedOffers_. // Just skip it. It will be deleted. - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "advanceNode: PAST INTERNAL ERROR " << " FORWARD CONFIRM: OFFER NON-POSITIVE:" << " node.saTakerPays=" << node().saTakerPays @@ -257,7 +258,7 @@ TER PathCursor::advanceNode (bool const bReverse) const { // Reverse should have previously put bad offer in list. // An internal error previously left a bad offer. - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "advanceNode: INTERNAL ERROR" <<" FORWARD NEWLY FOUND: OFFER NON-POSITIVE:" @@ -294,7 +295,7 @@ TER PathCursor::advanceNode (bool const bReverse) const { // Temporarily unfunded. Another node uses this source, // ignore in this offer. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: temporarily unfunded offer" << " (forward)"; continue; @@ -314,7 +315,7 @@ TER PathCursor::advanceNode (bool const bReverse) const { // Temporarily unfunded. Another node uses this source, // ignore in this offer. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: temporarily unfunded offer" <<" (reverse)"; continue; @@ -330,13 +331,13 @@ TER PathCursor::advanceNode (bool const bReverse) const node().saOfferFunds = accountFunds(view(), node().offerOwnerAccount_, node().saTakerGets, - fhZERO_IF_FROZEN); + fhZERO_IF_FROZEN, viewJ); // Funds held. if (node().saOfferFunds <= zero) { // Offer is unfunded. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: unfunded offer"; if (bReverse && !bFoundReverse && !bFoundPast) @@ -362,7 +363,7 @@ TER PathCursor::advanceNode (bool const bReverse) const && !bFoundReverse) // New to pass. { // Consider source mentioned by current path state. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: remember=" << node().offerOwnerAccount_ << "/" @@ -381,12 +382,12 @@ TER PathCursor::advanceNode (bool const bReverse) const if (resultCode == tesSUCCESS) { - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "advanceNode: node.offerIndex_=" << node().offerIndex_; } else { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "advanceNode: resultCode=" << transToken (resultCode); } diff --git a/src/ripple/app/paths/cursor/DeliverNodeForward.cpp b/src/ripple/app/paths/cursor/DeliverNodeForward.cpp index 9bc56e1fbd..4e9a629dcc 100644 --- a/src/ripple/app/paths/cursor/DeliverNodeForward.cpp +++ b/src/ripple/app/paths/cursor/DeliverNodeForward.cpp @@ -47,6 +47,7 @@ TER PathCursor::deliverNodeForward ( saInFees.clear (saInReq); int loopCount = 0; + auto viewJ = rippleCalc_.logs_.journal ("View"); // XXX Perhaps make sure do not exceed node().saRevDeliver as another way to // stop? @@ -58,7 +59,7 @@ TER PathCursor::deliverNodeForward ( CALC_NODE_DELIVER_MAX_LOOPS_MQ : CALC_NODE_DELIVER_MAX_LOOPS)) { - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "deliverNodeForward: max loops cndf"; return telFAILED_PROCESSING; } @@ -74,7 +75,7 @@ TER PathCursor::deliverNodeForward ( } else if (!node().offerIndex_) { - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "deliverNodeForward: INTERNAL ERROR: Ran out of offers."; return telFAILED_PROCESSING; } @@ -137,7 +138,7 @@ TER PathCursor::deliverNodeForward ( // Will be determined by adjusted saInPassAct. STAmount saInPassFees; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeForward:" << " nodeIndex_=" << nodeIndex_ << " saOutFunded=" << saOutFunded @@ -156,7 +157,7 @@ TER PathCursor::deliverNodeForward ( // FIXME: We remove an offer if WE didn't want anything out of it? if (!node().saTakerPays || saInSum <= zero) { - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "deliverNodeForward: Microscopic offer unfunded."; // After math offer is effectively unfunded. @@ -168,7 +169,7 @@ TER PathCursor::deliverNodeForward ( if (!saInFunded) { // Previous check should catch this. - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "deliverNodeForward: UNREACHABLE REACHED"; // After math offer is effectively unfunded. @@ -187,7 +188,7 @@ TER PathCursor::deliverNodeForward ( saOutPassAct = saOutPassMax; saInPassFees = saInPassFeesMax; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeForward: ? --> OFFER --> account:" << " offerOwnerAccount_=" << node().offerOwnerAccount_ @@ -201,7 +202,7 @@ TER PathCursor::deliverNodeForward ( resultCode = accountSend(view(), node().offerOwnerAccount_, nextNode().account_, - saOutPassAct); + saOutPassAct, viewJ); if (resultCode != tesSUCCESS) break; @@ -258,15 +259,16 @@ TER PathCursor::deliverNodeForward ( accountSend(view(), node().offerOwnerAccount_, id, - outPassTotal); + outPassTotal, + viewJ); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeForward: ? --> OFFER --> offer:" << " saOutPassAct=" << saOutPassAct << " saOutPassFees=" << saOutPassFees; } - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeForward: " << " nodeIndex_=" << nodeIndex_ << " node().saTakerGets=" << node().saTakerGets @@ -292,7 +294,8 @@ TER PathCursor::deliverNodeForward ( resultCode = accountSend(view(), id, node().offerOwnerAccount_, - saInPassAct); + saInPassAct, + viewJ); if (resultCode != tesSUCCESS) break; @@ -307,7 +310,7 @@ TER PathCursor::deliverNodeForward ( if (saTakerPaysNew < zero || saTakerGetsNew < zero) { - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "deliverNodeForward: NEGATIVE:" << " saTakerPaysNew=" << saTakerPaysNew << " saTakerGetsNew=" << saTakerGetsNew; @@ -325,7 +328,7 @@ TER PathCursor::deliverNodeForward ( { // Offer became unfunded. - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "deliverNodeForward: unfunded:" << " saOutPassAct=" << saOutPassAct << " saOutFunded=" << saOutFunded; @@ -352,7 +355,7 @@ TER PathCursor::deliverNodeForward ( } } - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeForward<" << " nodeIndex_=" << nodeIndex_ << " saInAct=" << saInAct diff --git a/src/ripple/app/paths/cursor/DeliverNodeReverse.cpp b/src/ripple/app/paths/cursor/DeliverNodeReverse.cpp index bbb963ac27..c9235251d0 100644 --- a/src/ripple/app/paths/cursor/DeliverNodeReverse.cpp +++ b/src/ripple/app/paths/cursor/DeliverNodeReverse.cpp @@ -64,7 +64,7 @@ TER PathCursor::deliverNodeReverseImpl ( // only on first increment, then it could be a limit on the forward pass. saOutAct.clear (saOutReq); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse>" << " saOutAct=" << saOutAct << " saOutReq=" << saOutReq @@ -73,6 +73,7 @@ TER PathCursor::deliverNodeReverseImpl ( assert (saOutReq != zero); int loopCount = 0; + auto viewJ = rippleCalc_.logs_.journal ("View"); // While we did not deliver as much as requested: while (saOutAct < saOutReq) @@ -82,7 +83,7 @@ TER PathCursor::deliverNodeReverseImpl ( CALC_NODE_DELIVER_MAX_LOOPS_MQ : CALC_NODE_DELIVER_MAX_LOOPS)) { - WriteLog (lsFATAL, RippleCalc) << "loop count exceeded"; + JLOG (j_.fatal) << "loop count exceeded"; return telFAILED_PROCESSING; } @@ -101,7 +102,7 @@ TER PathCursor::deliverNodeReverseImpl ( ? STAmount::saOne // No fee. : node().transferRate_; // Transfer rate of issuer. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse:" << " offerOwnerAccount_=" << node().offerOwnerAccount_ @@ -121,7 +122,7 @@ TER PathCursor::deliverNodeReverseImpl ( // Set initial rate. node().saRateMax = saOutFeeRate; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse: Set initial rate:" << " node().saRateMax=" << node().saRateMax << " saOutFeeRate=" << saOutFeeRate; @@ -129,7 +130,7 @@ TER PathCursor::deliverNodeReverseImpl ( else if (saOutFeeRate > node().saRateMax) { // Offer exceeds initial rate. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse: Offer exceeds initial rate:" << " node().saRateMax=" << node().saRateMax << " saOutFeeRate=" << saOutFeeRate; @@ -150,7 +151,7 @@ TER PathCursor::deliverNodeReverseImpl ( node().saRateMax = saOutFeeRate; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse: Reducing rate:" << " node().saRateMax=" << node().saRateMax; } @@ -173,7 +174,7 @@ TER PathCursor::deliverNodeReverseImpl ( saOutPassAct, saOutFeeRate, saOutPassAct.issue (), false); // Offer out with fees. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse:" << " saOutReq=" << saOutReq << " saOutAct=" << saOutAct @@ -194,7 +195,7 @@ TER PathCursor::deliverNodeReverseImpl ( saOutPlusFees.issue (), true); saOutPassAct = std::min (saOutPassReq, fee); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse: Total exceeds fees:" << " saOutPassAct=" << saOutPassAct << " saOutPlusFees=" << saOutPlusFees @@ -207,7 +208,7 @@ TER PathCursor::deliverNodeReverseImpl ( STAmount saInPassReq = std::min (node().saTakerPays, outputFee); STAmount saInPassAct; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse:" << " outputFee=" << outputFee << " saInPassReq=" << saInPassReq @@ -218,7 +219,7 @@ TER PathCursor::deliverNodeReverseImpl ( if (!saInPassReq) // FIXME: This is bogus { // After rounding did not want anything. - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "deliverNodeReverse: micro offer is unfunded."; node().bEntryAdvance = true; @@ -241,7 +242,7 @@ TER PathCursor::deliverNodeReverseImpl ( saInPassAct = saInPassReq; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse: account --> OFFER --> ? :" << " saInPassAct=" << saInPassAct; } @@ -256,7 +257,7 @@ TER PathCursor::deliverNodeReverseImpl ( saInPassReq, saInPassAct); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse: offer --> OFFER --> ? :" << " saInPassAct=" << saInPassAct; } @@ -274,7 +275,7 @@ TER PathCursor::deliverNodeReverseImpl ( saOutPassAct, saOutFeeRate, saOutPassAct.issue (), true); saOutPlusFees = std::min (node().saOfferFunds, outputFees); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse: adjusted:" << " saOutPassAct=" << saOutPassAct << " saOutPlusFees=" << saOutPlusFees; @@ -296,7 +297,7 @@ TER PathCursor::deliverNodeReverseImpl ( // // Must reset balances when going forward to perform actual transfers. resultCode = accountSend(view(), - node().offerOwnerAccount_, node().issue_.account, saOutPassAct); + node().offerOwnerAccount_, node().issue_.account, saOutPassAct, viewJ); if (resultCode != tesSUCCESS) break; @@ -307,7 +308,7 @@ TER PathCursor::deliverNodeReverseImpl ( if (saTakerPaysNew < zero || saTakerGetsNew < zero) { - WriteLog (lsWARNING, RippleCalc) + JLOG (j_.warning) << "deliverNodeReverse: NEGATIVE:" << " node().saTakerPaysNew=" << saTakerPaysNew << " node().saTakerGetsNew=" << saTakerGetsNew; @@ -324,7 +325,7 @@ TER PathCursor::deliverNodeReverseImpl ( if (saOutPassAct == node().saTakerGets) { // Offer became unfunded. - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "deliverNodeReverse: offer became unfunded."; node().bEntryAdvance = true; @@ -352,7 +353,7 @@ TER PathCursor::deliverNodeReverseImpl ( // Unable to meet request, consider path dry. // Design invariant: if nothing was actually delivered, return tecPATH_DRY. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "deliverNodeReverse<" << " saOutAct=" << saOutAct << " saOutReq=" << saOutReq diff --git a/src/ripple/app/paths/cursor/ForwardLiquidityForAccount.cpp b/src/ripple/app/paths/cursor/ForwardLiquidityForAccount.cpp index 197866ff86..137a0701f3 100644 --- a/src/ripple/app/paths/cursor/ForwardLiquidityForAccount.cpp +++ b/src/ripple/app/paths/cursor/ForwardLiquidityForAccount.cpp @@ -44,6 +44,7 @@ TER PathCursor::forwardLiquidityForAccount () const { TER resultCode = tesSUCCESS; auto const lastNodeIndex = pathState_.nodes().size () - 1; + auto viewJ = rippleCalc_.logs_.journal ("View"); std::uint64_t uRateMax = 0; @@ -79,7 +80,7 @@ TER PathCursor::forwardLiquidityForAccount () const // For !previousNode().isAccount() auto saPrvDeliverAct = previousNode().saFwdDeliver.zeroed (); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount> " << "nodeIndex_=" << nodeIndex_ << "/" << lastNodeIndex << " previousNode.saFwdRedeem:" << previousNode().saFwdRedeem @@ -126,7 +127,7 @@ TER PathCursor::forwardLiquidityForAccount () const pathState_.setInPass (pathState_.inPass() + node().saFwdIssue); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount: ^ --> " << "ACCOUNT --> account :" << " saInReq=" << pathState_.inReq() @@ -139,7 +140,7 @@ TER PathCursor::forwardLiquidityForAccount () const else if (nodeIndex_ == lastNodeIndex) { // account --> ACCOUNT --> $ - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount: account --> " << "ACCOUNT --> $ :" << " previousAccountID=" @@ -170,7 +171,7 @@ TER PathCursor::forwardLiquidityForAccount () const previousAccountID, node().account_, previousNode().saFwdRedeem + previousNode().saFwdIssue, - false); + false, viewJ); } else { @@ -181,7 +182,7 @@ TER PathCursor::forwardLiquidityForAccount () const else { // account --> ACCOUNT --> account - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount: account --> " << "ACCOUNT --> account"; @@ -270,7 +271,7 @@ TER PathCursor::forwardLiquidityForAccount () const previousAccountID, node().account_, previousNode().saFwdRedeem + previousNode().saFwdIssue, - false) + false, viewJ) : tecPATH_DRY; } } @@ -285,7 +286,7 @@ TER PathCursor::forwardLiquidityForAccount () const if (nodeIndex_) { // Non-XRP, current node is the issuer. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount: account --> " << "ACCOUNT --> offer"; @@ -334,7 +335,7 @@ TER PathCursor::forwardLiquidityForAccount () const ? rippleCredit(view(), previousAccountID, node().account_, previousNode().saFwdRedeem + previousNode().saFwdIssue, - false) + false, viewJ) : tecPATH_DRY; // Didn't actually deliver anything. } else @@ -357,7 +358,7 @@ TER PathCursor::forwardLiquidityForAccount () const node().account_, xrpCurrency(), xrpAccount(), - fhIGNORE_FREEZE)); // XRP can't be frozen + fhIGNORE_FREEZE, viewJ)); // XRP can't be frozen } @@ -374,7 +375,7 @@ TER PathCursor::forwardLiquidityForAccount () const // We could be delivering to multiple accounts, so we don't know // which ripple balance will be adjusted. Assume just issuing. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount: ^ --> " << "ACCOUNT -- !XRP --> offer"; @@ -384,13 +385,13 @@ TER PathCursor::forwardLiquidityForAccount () const } else { - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount: ^ --> " << "ACCOUNT -- XRP --> offer"; // Deliver XRP to limbo. resultCode = accountSend(view(), - node().account_, xrpAccount(), node().saFwdDeliver); + node().account_, xrpAccount(), node().saFwdDeliver, viewJ); } } } @@ -399,7 +400,7 @@ TER PathCursor::forwardLiquidityForAccount () const if (nodeIndex_ == lastNodeIndex) { // offer --> ACCOUNT --> $ - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount: offer --> " << "ACCOUNT --> $ : " << previousNode().saFwdDeliver; @@ -413,7 +414,7 @@ TER PathCursor::forwardLiquidityForAccount () const else { // offer --> ACCOUNT --> account - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount: offer --> " << "ACCOUNT --> account"; @@ -469,7 +470,7 @@ TER PathCursor::forwardLiquidityForAccount () const { // offer --> ACCOUNT --> offer // deliver/redeem -> deliver/issue. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidityForAccount: offer --> ACCOUNT --> offer"; node().saFwdDeliver.clear (node().saRevDeliver); diff --git a/src/ripple/app/paths/cursor/Liquidity.cpp b/src/ripple/app/paths/cursor/Liquidity.cpp index f60d37c296..d42ed65cdb 100644 --- a/src/ripple/app/paths/cursor/Liquidity.cpp +++ b/src/ripple/app/paths/cursor/Liquidity.cpp @@ -34,14 +34,14 @@ TER PathCursor::liquidity () const for (pc.nodeIndex_ = pc.nodeSize(); pc.nodeIndex_--; ) { - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidity>" << " nodeIndex=" << pc.nodeIndex_ << ".issue_.account=" << to_string (pc.node().issue_.account); resultCode = pc.reverseLiquidity(); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidity< " << "nodeIndex=" << pc.nodeIndex_ << " resultCode=" << transToken (resultCode) @@ -53,7 +53,7 @@ TER PathCursor::liquidity () const } // VFALCO-FIXME this generates errors - // WriteLog (lsTRACE, RippleCalc) + // JLOG (j_.trace) // << "nextIncrement: Path after reverse: " << pathState_.getJson (); if (resultCode != tesSUCCESS) @@ -63,14 +63,14 @@ TER PathCursor::liquidity () const for (pc.nodeIndex_ = 0; pc.nodeIndex_ < pc.nodeSize(); ++pc.nodeIndex_) { - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidity> nodeIndex=" << nodeIndex_; resultCode = pc.forwardLiquidity(); if (resultCode != tesSUCCESS) return resultCode; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "forwardLiquidity<" << " nodeIndex:" << pc.nodeIndex_ << " resultCode:" << resultCode; diff --git a/src/ripple/app/paths/cursor/NextIncrement.cpp b/src/ripple/app/paths/cursor/NextIncrement.cpp index 6140fcde33..4dbbdb01dd 100644 --- a/src/ripple/app/paths/cursor/NextIncrement.cpp +++ b/src/ripple/app/paths/cursor/NextIncrement.cpp @@ -39,7 +39,7 @@ void PathCursor::nextIncrement () const // The next state is what is available in preference order. // This is calculated when referenced accounts changed. // VFALCO-FIXME this generates errors - // WriteLog (lsTRACE, RippleCalc) + // JLOG (j_.trace) // << "nextIncrement: Path In: " << pathState_.getJson (); auto status = liquidity(); @@ -61,7 +61,7 @@ void PathCursor::nextIncrement () const pathState_.outPass(), pathState_.inPass())); // VFALCO-FIXME this generates errors - // WriteLog (lsTRACE, RippleCalc) + // JLOG (j_.trace) // << "nextIncrement: Path after forward: " << pathState_.getJson (); } else diff --git a/src/ripple/app/paths/cursor/PathCursor.h b/src/ripple/app/paths/cursor/PathCursor.h index 6b7f48acfc..3d133c92c7 100644 --- a/src/ripple/app/paths/cursor/PathCursor.h +++ b/src/ripple/app/paths/cursor/PathCursor.h @@ -42,11 +42,13 @@ public: RippleCalc& rippleCalc, PathState& pathState, bool multiQuality, + beast::Journal j, NodeIndex nodeIndex = 0) : rippleCalc_(rippleCalc), pathState_(pathState), multiQuality_(multiQuality), - nodeIndex_(restrict(nodeIndex)) + nodeIndex_(restrict(nodeIndex)), + j_ (j) { } @@ -57,7 +59,7 @@ private: PathCursor increment(int delta = 1) const { - return {rippleCalc_, pathState_, multiQuality_, nodeIndex_ + delta}; + return {rippleCalc_, pathState_, multiQuality_, j_, nodeIndex_ + delta}; } TER liquidity() const; @@ -138,6 +140,7 @@ private: PathState& pathState_; bool multiQuality_; NodeIndex nodeIndex_; + beast::Journal j_; }; } // path diff --git a/src/ripple/app/paths/cursor/ReverseLiquidity.cpp b/src/ripple/app/paths/cursor/ReverseLiquidity.cpp index 96eeea699e..fb8e4157d1 100644 --- a/src/ripple/app/paths/cursor/ReverseLiquidity.cpp +++ b/src/ripple/app/paths/cursor/ReverseLiquidity.cpp @@ -65,7 +65,7 @@ TER PathCursor::reverseLiquidity () const // Otherwise the node is an Offer. if (isXRP (nextNode().account_)) { - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForOffer: " << "OFFER --> offer: nodeIndex_=" << nodeIndex_; return tesSUCCESS; @@ -78,7 +78,7 @@ TER PathCursor::reverseLiquidity () const // Next is an account node, resolve current offer node's deliver. STAmount saDeliverAct; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForOffer: OFFER --> account:" << " nodeIndex_=" << nodeIndex_ << " saRevDeliver=" << node().saRevDeliver; diff --git a/src/ripple/app/paths/cursor/ReverseLiquidityForAccount.cpp b/src/ripple/app/paths/cursor/ReverseLiquidityForAccount.cpp index cdf46f4e64..576844c83c 100644 --- a/src/ripple/app/paths/cursor/ReverseLiquidityForAccount.cpp +++ b/src/ripple/app/paths/cursor/ReverseLiquidityForAccount.cpp @@ -105,7 +105,7 @@ TER PathCursor::reverseLiquidityForAccount () const node().issue_.currency) : STAmount (node().issue_); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount>" << " nodeIndex_=" << nodeIndex_ << "/" << lastNodeIndex << " previousAccountID=" << previousAccountID @@ -143,7 +143,7 @@ TER PathCursor::reverseLiquidityForAccount () const // For !nextNodeIsAccount auto saCurDeliverAct = node().saRevDeliver.zeroed(); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount:" << " saPrvRedeemReq:" << saPrvRedeemReq << " saPrvIssueReq:" << saPrvIssueReq @@ -154,7 +154,7 @@ TER PathCursor::reverseLiquidityForAccount () const << " saNxtOwed:" << saNxtOwed; // VFALCO-FIXME this generates errors - //WriteLog (lsTRACE, RippleCalc) << pathState_.getJson (); + //JLOG (j_.trace) << pathState_.getJson (); // Current redeem req can't be more than IOUs on hand. assert (!node().saRevRedeem || -saNxtOwed >= node().saRevRedeem); @@ -187,7 +187,7 @@ TER PathCursor::reverseLiquidityForAccount () const saPrvLimit + saPrvOwed); auto saCurWantedAct = saCurWantedReq.zeroed (); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: account --> " << "ACCOUNT --> $ :" << " saCurWantedReq=" << saCurWantedReq; @@ -202,7 +202,7 @@ TER PathCursor::reverseLiquidityForAccount () const uRateMax = STAmount::uRateOne; - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: Redeem at 1:1" << " saPrvRedeemReq=" << saPrvRedeemReq << " (available) previousNode.saRevRedeem=" @@ -235,7 +235,7 @@ TER PathCursor::reverseLiquidityForAccount () const saCurWantedAct, uRateMax); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: Issuing: Rate: " << "quality in : 1.0" << " previousNode.saRevIssue:" << previousNode().saRevIssue @@ -274,7 +274,7 @@ TER PathCursor::reverseLiquidityForAccount () const saCurRedeemAct, uRateMax); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: " << "Rate : 1.0 : quality out" << " previousNode.saRevRedeem:" << previousNode().saRevRedeem @@ -298,7 +298,7 @@ TER PathCursor::reverseLiquidityForAccount () const saCurRedeemAct, uRateMax); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: " << "Rate: quality in : quality out:" << " previousNode.saRevIssue:" << previousNode().saRevIssue @@ -324,7 +324,7 @@ TER PathCursor::reverseLiquidityForAccount () const saCurIssueAct, uRateMax); - WriteLog (lsDEBUG, RippleCalc) + JLOG (j_.debug) << "reverseLiquidityForAccount: " << "Rate : 1.0 : transfer_rate:" << " previousNode.saRevRedeem:" << previousNode().saRevRedeem @@ -352,7 +352,7 @@ TER PathCursor::reverseLiquidityForAccount () const saCurIssueAct, uRateMax); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: " << "Rate: quality in : 1.0:" << " previousNode.saRevIssue:" << previousNode().saRevIssue @@ -365,7 +365,7 @@ TER PathCursor::reverseLiquidityForAccount () const terResult = tecPATH_DRY; } - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: " << "^|account --> ACCOUNT --> account :" << " node.saRevRedeem:" << node().saRevRedeem @@ -380,7 +380,7 @@ TER PathCursor::reverseLiquidityForAccount () const // account --> ACCOUNT --> offer // Note: deliver is always issue as ACCOUNT is the issuer for the offer // input. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: " << "account --> ACCOUNT --> offer"; @@ -434,7 +434,7 @@ TER PathCursor::reverseLiquidityForAccount () const terResult = tecPATH_DRY; } - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: " << " node.saRevDeliver:" << node().saRevDeliver << " saCurDeliverAct:" << saCurDeliverAct @@ -453,7 +453,7 @@ TER PathCursor::reverseLiquidityForAccount () const pathState_.outReq() - pathState_.outAct(); STAmount saCurWantedAct = saCurWantedReq.zeroed(); - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: " << "offer --> ACCOUNT --> $ :" << " saCurWantedReq:" << saCurWantedReq @@ -463,7 +463,7 @@ TER PathCursor::reverseLiquidityForAccount () const if (saCurWantedReq <= zero) { assert(false); - WriteLog (lsFATAL, RippleCalc) << "CurWantReq was not positive"; + JLOG (j_.fatal) << "CurWantReq was not positive"; return tefEXCEPTION; } @@ -497,7 +497,7 @@ TER PathCursor::reverseLiquidityForAccount () const terResult = tecPATH_DRY; } - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount:" << " previousNode().saRevDeliver:" << previousNode().saRevDeliver << " saPrvDeliverReq:" << saPrvDeliverReq @@ -508,7 +508,7 @@ TER PathCursor::reverseLiquidityForAccount () const { // offer --> ACCOUNT --> account // Note: offer is always delivering(redeeming) as account is issuer. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: " << "offer --> ACCOUNT --> account :" << " node.saRevRedeem:" << node().saRevRedeem @@ -554,7 +554,7 @@ TER PathCursor::reverseLiquidityForAccount () const uRateMax); } - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount:" << " saCurRedeemAct:" << saCurRedeemAct << " node.saRevRedeem:" << node().saRevRedeem @@ -572,7 +572,7 @@ TER PathCursor::reverseLiquidityForAccount () const { // offer --> ACCOUNT --> offer // deliver/redeem -> deliver/issue. - WriteLog (lsTRACE, RippleCalc) + JLOG (j_.trace) << "reverseLiquidityForAccount: offer --> ACCOUNT --> offer"; // Rate : 1.0 : transfer_rate diff --git a/src/ripple/app/paths/cursor/RippleLiquidity.cpp b/src/ripple/app/paths/cursor/RippleLiquidity.cpp index e5a808ead1..a2b99af458 100644 --- a/src/ripple/app/paths/cursor/RippleLiquidity.cpp +++ b/src/ripple/app/paths/cursor/RippleLiquidity.cpp @@ -57,7 +57,7 @@ void rippleLiquidity ( STAmount& saCurAct, // <-> out limit including achieved so far: <-- <= --> std::uint64_t& uRateMax) { - WriteLog (lsTRACE, RippleCalc) + JLOG (rippleCalc.j_.trace) << "rippleLiquidity>" << " uQualityIn=" << uQualityIn << " uQualityOut=" << uQualityOut @@ -84,7 +84,7 @@ void rippleLiquidity ( // How much could possibly flow through the current node? const STAmount saCur = saCurReq - saCurAct; - WriteLog (lsTRACE, RippleCalc) + JLOG (rippleCalc.j_.trace) << "rippleLiquidity: " << " bPrvUnlimited=" << bPrvUnlimited << " saPrv=" << saPrv @@ -97,7 +97,7 @@ void rippleLiquidity ( if (uQualityIn >= uQualityOut) { // You're getting better quality than you asked for, so no fee. - WriteLog (lsTRACE, RippleCalc) << "rippleLiquidity: No fees"; + JLOG (rippleCalc.j_.trace) << "rippleLiquidity: No fees"; // Only process if the current rate, 1:1, is not worse than the previous // rate, uRateMax - otherwise there is no flow. @@ -127,7 +127,7 @@ void rippleLiquidity ( else { // If the quality is worse than the previous - WriteLog (lsTRACE, RippleCalc) << "rippleLiquidity: Fee"; + JLOG (rippleCalc.j_.trace) << "rippleLiquidity: Fee"; std::uint64_t uRate = getRate ( STAmount (uQualityOut), STAmount (uQualityIn)); @@ -146,7 +146,7 @@ void rippleLiquidity ( STAmount saCurIn = divRound ( numerator, uQualityIn, {currency, uCurIssuerID}, true); - WriteLog (lsTRACE, RippleCalc) + JLOG (rippleCalc.j_.trace) << "rippleLiquidity:" << " bPrvUnlimited=" << bPrvUnlimited << " saPrv=" << saPrv @@ -157,7 +157,7 @@ void rippleLiquidity ( // All of current. Some amount of previous. saCurAct += saCur; saPrvAct += saCurIn; - WriteLog (lsTRACE, RippleCalc) + JLOG (rippleCalc.j_.trace) << "rippleLiquidity:3c:" << " saCurReq=" << saCurReq << " saPrvAct=" << saPrvAct; @@ -179,7 +179,7 @@ void rippleLiquidity ( STAmount saCurOut = divRound ( numerator, uQualityOut, issue, true); - WriteLog (lsTRACE, RippleCalc) + JLOG (rippleCalc.j_.trace) << "rippleLiquidity:4: saCurReq=" << saCurReq; saCurAct += saCurOut; @@ -190,7 +190,7 @@ void rippleLiquidity ( } } - WriteLog (lsTRACE, RippleCalc) + JLOG (rippleCalc.j_.trace) << "rippleLiquidity<" << " uQualityIn=" << uQualityIn << " uQualityOut=" << uQualityOut diff --git a/src/ripple/app/tx/Transaction.h b/src/ripple/app/tx/Transaction.h index 193aaad8c7..ef6e68c1d2 100644 --- a/src/ripple/app/tx/Transaction.h +++ b/src/ripple/app/tx/Transaction.h @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace ripple { @@ -169,6 +170,7 @@ private: STTx::pointer mTransaction; Application& mApp; + beast::Journal j_; }; } // ripple diff --git a/src/ripple/app/tx/TransactionAcquire.h b/src/ripple/app/tx/TransactionAcquire.h index 42050df31e..2c07028342 100644 --- a/src/ripple/app/tx/TransactionAcquire.h +++ b/src/ripple/app/tx/TransactionAcquire.h @@ -58,6 +58,7 @@ private: std::shared_ptr mMap; bool mHaveRoot; + beast::Journal j_; void onTimer (bool progress, ScopedLockType& peerSetLock); diff --git a/src/ripple/app/tx/impl/BookTip.cpp b/src/ripple/app/tx/impl/BookTip.cpp index 07286fd202..954e44b5f0 100644 --- a/src/ripple/app/tx/impl/BookTip.cpp +++ b/src/ripple/app/tx/impl/BookTip.cpp @@ -19,6 +19,7 @@ #include #include +#include namespace ripple { @@ -31,13 +32,14 @@ BookTip::BookTip (ApplyView& view, BookRef book) } bool -BookTip::step () +BookTip::step (Logs& l) { + auto viewJ = l.journal ("View"); if (m_valid) { if (m_entry) { - offerDelete (view_, m_entry); + offerDelete (view_, m_entry, viewJ); m_entry = nullptr; } } @@ -56,7 +58,7 @@ BookTip::step () unsigned int di = 0; std::shared_ptr dir; - if (dirFirst (view_, *first_page, dir, di, m_index)) + if (dirFirst (view_, *first_page, dir, di, m_index, viewJ)) { m_dir = dir->key(); m_entry = view_.peek(keylet::offer(m_index)); diff --git a/src/ripple/app/tx/impl/BookTip.h b/src/ripple/app/tx/impl/BookTip.h index 7e8ffd7f3d..661b3cf0e8 100644 --- a/src/ripple/app/tx/impl/BookTip.h +++ b/src/ripple/app/tx/impl/BookTip.h @@ -29,6 +29,8 @@ namespace ripple { +class Logs; + /** Iterates and consumes raw offers in an order book. Offers are presented from highest quality to lowest quality. This will return all offers present including missing, invalid, unfunded, etc. @@ -78,7 +80,7 @@ public: @return `true` if there is a next offer */ bool - step (); + step (Logs& l); }; } diff --git a/src/ripple/app/tx/impl/CancelOffer.cpp b/src/ripple/app/tx/impl/CancelOffer.cpp index 7673503580..17c8a98a7f 100644 --- a/src/ripple/app/tx/impl/CancelOffer.cpp +++ b/src/ripple/app/tx/impl/CancelOffer.cpp @@ -77,7 +77,7 @@ CancelOffer::doApply () if (sleOffer) { j_.debug << "Trying to cancel offer #" << uOfferSequence; - return offerDelete (view(), sleOffer); + return offerDelete (view(), sleOffer, ctx_.app.journal ("View")); } j_.debug << "Offer #" << uOfferSequence << " can't be found."; diff --git a/src/ripple/app/tx/impl/CancelTicket.cpp b/src/ripple/app/tx/impl/CancelTicket.cpp index 65fb41bf00..ab147b7138 100644 --- a/src/ripple/app/tx/impl/CancelTicket.cpp +++ b/src/ripple/app/tx/impl/CancelTicket.cpp @@ -76,11 +76,12 @@ CancelTicket::doApply () std::uint64_t const hint (sleTicket->getFieldU64 (sfOwnerNode)); + auto viewJ = ctx_.app.journal ("View"); TER const result = dirDelete (ctx_.view (), false, hint, - getOwnerDirIndex (ticket_owner), ticketId, false, (hint == 0)); + getOwnerDirIndex (ticket_owner), ticketId, false, (hint == 0), viewJ); adjustOwnerCount(view(), view().peek( - keylet::account(ticket_owner)), -1); + keylet::account(ticket_owner)), -1, viewJ); ctx_.view ().erase (sleTicket); return result; diff --git a/src/ripple/app/tx/impl/CreateOffer.cpp b/src/ripple/app/tx/impl/CreateOffer.cpp index 3c05575083..58bcd3147d 100644 --- a/src/ripple/app/tx/impl/CreateOffer.cpp +++ b/src/ripple/app/tx/impl/CreateOffer.cpp @@ -190,7 +190,7 @@ CreateOffer::dry_offer (ApplyView& view, Offer const& offer) if (offer.fully_consumed ()) return true; auto const amount = accountFunds(view, offer.owner(), - offer.amount().out, fhZERO_IF_FROZEN); + offer.amount().out, fhZERO_IF_FROZEN, ctx_.app.journal ("View")); return (amount <= zero); } @@ -267,10 +267,13 @@ CreateOffer::bridged_cross ( // Note the subtle distinction here: self-offers encountered in the // bridge are taken, but self-offers encountered in the direct book // are not. - bool have_bridge = offers_leg1.step () && offers_leg2.step (); - bool have_direct = step_account (offers_direct, taker); + auto& logs = ctx_.app.logs(); + bool have_bridge = offers_leg1.step (logs) && offers_leg2.step (logs); + bool have_direct = step_account (offers_direct, taker, logs); int count = 0; + auto viewJ = ctx_.app.journal ("View"); + // Modifying the order or logic of the operations in the loop will cause // a protocol breaking change. while (have_direct || have_bridge) @@ -305,7 +308,7 @@ CreateOffer::bridged_cross ( j_.debug << " funds: " << accountFunds(view, offers_direct.tip ().owner (), offers_direct.tip ().amount ().out, - fhIGNORE_FREEZE); + fhIGNORE_FREEZE, viewJ); } cross_result = taker.cross(offers_direct.tip ()); @@ -315,7 +318,7 @@ CreateOffer::bridged_cross ( if (dry_offer (view, offers_direct.tip ())) { direct_consumed = true; - have_direct = step_account (offers_direct, taker); + have_direct = step_account (offers_direct, taker, ctx_.app.logs()); } } else @@ -325,12 +328,12 @@ CreateOffer::bridged_cross ( auto const owner1_funds_before = accountFunds(view, offers_leg1.tip ().owner (), offers_leg1.tip ().amount ().out, - fhIGNORE_FREEZE); + fhIGNORE_FREEZE, viewJ); auto const owner2_funds_before = accountFunds(view, offers_leg2.tip ().owner (), offers_leg2.tip ().amount ().out, - fhIGNORE_FREEZE); + fhIGNORE_FREEZE, viewJ); j_.debug << count << " Bridge:"; j_.debug << " offer1: " << offers_leg1.tip (); @@ -352,12 +355,12 @@ CreateOffer::bridged_cross ( if (dry_offer (view, offers_leg1.tip ())) { leg1_consumed = true; - have_bridge = (have_bridge && offers_leg1.step ()); + have_bridge = (have_bridge && offers_leg1.step (logs)); } if (dry_offer (view, offers_leg2.tip ())) { leg2_consumed = true; - have_bridge = (have_bridge && offers_leg2.step ()); + have_bridge = (have_bridge && offers_leg2.step (logs)); } } @@ -405,7 +408,7 @@ CreateOffer::direct_cross ( TER cross_result (tesSUCCESS); int count = 0; - bool have_offer = step_account (offers, taker); + bool have_offer = step_account (offers, taker, ctx_.app.logs()); // Modifying the order or logic of the operations in the loop will cause // a protocol breaking change. @@ -428,7 +431,8 @@ CreateOffer::direct_cross ( j_.debug << " out: " << offer.amount ().out; j_.debug << " owner: " << offer.owner (); j_.debug << " funds: " << accountFunds(view, - offer.owner (), offer.amount ().out, fhIGNORE_FREEZE); + offer.owner (), offer.amount ().out, fhIGNORE_FREEZE, + ctx_.app.journal ("View")); } cross_result = taker.cross (offer); @@ -438,7 +442,7 @@ CreateOffer::direct_cross ( if (dry_offer (view, offer)) { direct_consumed = true; - have_offer = step_account (offers, taker); + have_offer = step_account (offers, taker, ctx_.app.logs()); } if (cross_result != tesSUCCESS) @@ -474,9 +478,9 @@ CreateOffer::direct_cross ( // that are from the taker or which cross the taker's threshold. // Return false if the is no offer in the book, true otherwise. bool -CreateOffer::step_account (OfferStream& stream, Taker const& taker) +CreateOffer::step_account (OfferStream& stream, Taker const& taker, Logs& logs) { - while (stream.step ()) + while (stream.step (logs)) { auto const& offer = stream.tip (); @@ -598,6 +602,8 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel) // end up on the books. std::uint64_t const uRate = getRate (saTakerGets, saTakerPays); + auto viewJ = ctx_.app.journal ("View"); + TER result = tesSUCCESS; // This is the ledger view that we work against. Transactions are applied @@ -611,7 +617,7 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel) result = tecFROZEN; } else if (accountFunds(view, account_, saTakerGets, - fhZERO_IF_FROZEN) <= zero) + fhZERO_IF_FROZEN, viewJ) <= zero) { if (j_.debug) j_.debug << "delay: Offers must be at least partially funded."; @@ -647,7 +653,7 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel) if (sleCancel) { j_.debug << "Create cancels order " << uCancelSequence; - result = offerDelete (view, sleCancel); + result = offerDelete (view, sleCancel, viewJ); } } @@ -812,12 +818,12 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel) getOwnerDirIndex (account_), offer_index, std::bind ( &ownerDirDescriber, std::placeholders::_1, - std::placeholders::_2, account_)); + std::placeholders::_2, account_), viewJ); if (result == tesSUCCESS) { // Update owner count. - adjustOwnerCount(view, sleCreator, 1); + adjustOwnerCount(view, sleCreator, 1, viewJ); if (j_.trace) j_.trace << "adding to book: " << to_string (saTakerPays.issue ()) << @@ -835,7 +841,8 @@ CreateOffer::applyGuts (ApplyView& view, ApplyView& view_cancel) &qualityDirDescriber, std::placeholders::_1, std::placeholders::_2, saTakerPays.getCurrency (), uPaysIssuerID, saTakerGets.getCurrency (), - uGetsIssuerID, uRate, std::ref(ctx_.app))); + uGetsIssuerID, uRate, std::ref(ctx_.app)), + viewJ); } if (result == tesSUCCESS) diff --git a/src/ripple/app/tx/impl/CreateOffer.h b/src/ripple/app/tx/impl/CreateOffer.h index 44abba2f99..d9677ae657 100644 --- a/src/ripple/app/tx/impl/CreateOffer.h +++ b/src/ripple/app/tx/impl/CreateOffer.h @@ -91,7 +91,7 @@ private: // Return false if the is no offer in the book, true otherwise. static bool - step_account (OfferStream& stream, Taker const& taker); + step_account (OfferStream& stream, Taker const& taker, Logs& logs); // True if the number of offers that have been crossed // exceeds the limit. diff --git a/src/ripple/app/tx/impl/CreateTicket.cpp b/src/ripple/app/tx/impl/CreateTicket.cpp index b04e6657fc..be472356c2 100644 --- a/src/ripple/app/tx/impl/CreateTicket.cpp +++ b/src/ripple/app/tx/impl/CreateTicket.cpp @@ -107,11 +107,13 @@ CreateTicket::doApply () ownerDirDescriber(p, b, account_); }; + auto viewJ = ctx_.app.journal ("View"); TER result = dirAdd(view(), hint, getOwnerDirIndex (account_), sleTicket->getIndex (), - describer); + describer, + viewJ); if (j_.trace) j_.trace << "Creating ticket " << to_string (sleTicket->getIndex ()) << @@ -123,7 +125,7 @@ CreateTicket::doApply () sleTicket->setFieldU64(sfOwnerNode, hint); // If we succeeded, the new entry counts agains the creator's reserve. - adjustOwnerCount(view(), sle, 1); + adjustOwnerCount(view(), sle, 1, viewJ); return result; } diff --git a/src/ripple/app/tx/impl/InboundTransactions.cpp b/src/ripple/app/tx/impl/InboundTransactions.cpp index d6586c64da..c494083acb 100644 --- a/src/ripple/app/tx/impl/InboundTransactions.cpp +++ b/src/ripple/app/tx/impl/InboundTransactions.cpp @@ -147,7 +147,7 @@ public: { protocol::TMLedgerData& packet = *packet_ptr; - WriteLog (lsTRACE, InboundLedger) << + JLOG (app_.journal("InboundLedger").trace) << "Got data (" << packet.nodes ().size () << ") " "for acquiring ledger: " << hash; diff --git a/src/ripple/app/tx/impl/OfferStream.cpp b/src/ripple/app/tx/impl/OfferStream.cpp index 57d486e441..f84aa91521 100644 --- a/src/ripple/app/tx/impl/OfferStream.cpp +++ b/src/ripple/app/tx/impl/OfferStream.cpp @@ -76,16 +76,17 @@ OfferStream::erase (ApplyView& view) } bool -OfferStream::step () +OfferStream::step (Logs& l) { // Modifying the order or logic of these // operations causes a protocol breaking change. + auto viewJ = l.journal ("View"); for(;;) { // BookTip::step deletes the current offer from the view before // advancing to the next (unless the ledger entry is missing). - if (! tip_.step()) + if (! tip_.step(l)) return false; std::shared_ptr entry = tip_.entry(); @@ -109,7 +110,7 @@ OfferStream::step () JLOG(j_.trace) << "Removing expired offer " << entry->getIndex(); offerDelete (cancelView_, - cancelView_.peek(keylet::offer(entry->key()))); + cancelView_.peek(keylet::offer(entry->key())), viewJ); continue; } @@ -123,14 +124,14 @@ OfferStream::step () JLOG(j_.warning) << "Removing bad offer " << entry->getIndex(); offerDelete (cancelView_, - cancelView_.peek(keylet::offer(entry->key()))); + cancelView_.peek(keylet::offer(entry->key())), viewJ); offer_ = Offer{}; continue; } // Calculate owner funds auto const owner_funds = accountFunds(view_, - offer_.owner(), amount.out, fhZERO_IF_FROZEN); + offer_.owner(), amount.out, fhZERO_IF_FROZEN, viewJ); // Check for unfunded offer if (owner_funds <= zero) @@ -139,12 +140,12 @@ OfferStream::step () // we haven't modified the balance and therefore the // offer is "found unfunded" versus "became unfunded" auto const original_funds = accountFunds(cancelView_, - offer_.owner(), amount.out, fhZERO_IF_FROZEN); + offer_.owner(), amount.out, fhZERO_IF_FROZEN, viewJ); if (original_funds == owner_funds) { offerDelete (cancelView_, cancelView_.peek( - keylet::offer(entry->key()))); + keylet::offer(entry->key())), viewJ); JLOG(j_.trace) << "Removing unfunded offer " << entry->getIndex(); } diff --git a/src/ripple/app/tx/impl/OfferStream.h b/src/ripple/app/tx/impl/OfferStream.h index 4257d997a4..5ec30e0067 100644 --- a/src/ripple/app/tx/impl/OfferStream.h +++ b/src/ripple/app/tx/impl/OfferStream.h @@ -113,7 +113,7 @@ public: @return `true` if there is a valid offer. */ bool - step (); + step (Logs& l); }; } diff --git a/src/ripple/app/tx/impl/Payment.cpp b/src/ripple/app/tx/impl/Payment.cpp index 5043775d47..b39e8f92c6 100644 --- a/src/ripple/app/tx/impl/Payment.cpp +++ b/src/ripple/app/tx/impl/Payment.cpp @@ -343,6 +343,7 @@ Payment::doApply () uDstAccountID, account_, spsPaths, + ctx_.app.logs(), &rcInput); // VFALCO NOTE We might not need to apply, depending // on the TER. But always applying *should* diff --git a/src/ripple/app/tx/impl/SetSignerList.cpp b/src/ripple/app/tx/impl/SetSignerList.cpp index 2eb4d94b50..fa6b5110bc 100644 --- a/src/ripple/app/tx/impl/SetSignerList.cpp +++ b/src/ripple/app/tx/impl/SetSignerList.cpp @@ -237,10 +237,11 @@ SetSignerList::replaceSignerList () view().insert (signerList); writeSignersToSLE (signerList); + auto viewJ = ctx_.app.journal ("View"); // Add the signer list to the account's directory. std::uint64_t hint; TER result = dirAdd(ctx_.view (), hint, ownerDirKeylet.key, - signerListKeylet.key, describeOwnerDir (account_)); + signerListKeylet.key, describeOwnerDir (account_), viewJ); JLOG(j_.trace) << "Create signer list for account " << toBase58(account_) << ": " << transHuman (result); @@ -251,7 +252,7 @@ SetSignerList::replaceSignerList () signerList->setFieldU64 (sfOwnerNode, hint); // If we succeeded, the new entry counts against the creator's reserve. - adjustOwnerCount(view(), sle, addedOwnerCount); + adjustOwnerCount(view(), sle, addedOwnerCount, viewJ); return result; } @@ -291,12 +292,13 @@ SetSignerList::removeSignersFromLedger (Keylet const& accountKeylet, // Remove the node from the account directory. auto const hint = (*signers)[sfOwnerNode]; + auto viewJ = ctx_.app.journal ("View"); TER const result = dirDelete(ctx_.view(), false, hint, - ownerDirKeylet.key, signerListKeylet.key, false, (hint == 0)); + ownerDirKeylet.key, signerListKeylet.key, false, (hint == 0), viewJ); if (result == tesSUCCESS) adjustOwnerCount(view(), - view().peek(accountKeylet), removeFromOwnerCount); + view().peek(accountKeylet), removeFromOwnerCount, viewJ); ctx_.view().erase (signers); diff --git a/src/ripple/app/tx/impl/SetTrust.cpp b/src/ripple/app/tx/impl/SetTrust.cpp index 405288d12b..50a39a6e6b 100644 --- a/src/ripple/app/tx/impl/SetTrust.cpp +++ b/src/ripple/app/tx/impl/SetTrust.cpp @@ -137,6 +137,8 @@ SetTrust::doApply () bool const bSetFreeze = (uTxFlags & tfSetFreeze); bool const bClearFreeze = (uTxFlags & tfClearFreeze); + auto viewJ = ctx_.app.journal ("View"); + if (bSetAuth && !(sle->getFieldU32 (sfFlags) & lsfRequireAuth)) { j_.trace << @@ -159,7 +161,7 @@ SetTrust::doApply () "Clearing redundant line."; return trustDelete (view(), - sleDelete, account_, uDstAccountID); + sleDelete, account_, uDstAccountID, viewJ); } else { @@ -336,7 +338,7 @@ SetTrust::doApply () { // Set reserve for low account. adjustOwnerCount(view(), - sleLowAccount, 1); + sleLowAccount, 1, viewJ); uFlagsOut |= lsfLowReserve; if (!bHigh) @@ -347,7 +349,7 @@ SetTrust::doApply () { // Clear reserve for low account. adjustOwnerCount(view(), - sleLowAccount, -1); + sleLowAccount, -1, viewJ); uFlagsOut &= ~lsfLowReserve; } @@ -355,7 +357,7 @@ SetTrust::doApply () { // Set reserve for high account. adjustOwnerCount(view(), - sleHighAccount, 1); + sleHighAccount, 1, viewJ); uFlagsOut |= lsfHighReserve; if (bHigh) @@ -366,7 +368,7 @@ SetTrust::doApply () { // Clear reserve for high account. adjustOwnerCount(view(), - sleHighAccount, -1); + sleHighAccount, -1, viewJ); uFlagsOut &= ~lsfHighReserve; } @@ -378,7 +380,7 @@ SetTrust::doApply () // Delete. terResult = trustDelete (view(), - sleRippleState, uLowAccountID, uHighAccountID); + sleRippleState, uLowAccountID, uHighAccountID, viewJ); } // Reserve is not scaled by load. else if (bReserveIncrease && mPriorBalance < reserveCreate) @@ -442,7 +444,7 @@ SetTrust::doApply () saBalance, saLimitAllow, // Limit for who is being charged. uQualityIn, - uQualityOut); + uQualityOut, viewJ); } return terResult; diff --git a/src/ripple/app/tx/impl/SusPay.cpp b/src/ripple/app/tx/impl/SusPay.cpp index 6171d2bdc4..4d4fe3c63b 100644 --- a/src/ripple/app/tx/impl/SusPay.cpp +++ b/src/ripple/app/tx/impl/SusPay.cpp @@ -232,7 +232,7 @@ SusPayCreate::doApply() uint64_t page; TER ter = dirAdd(ctx_.view(), page, keylet::ownerDir(account).key, - slep->key(), describeOwnerDir(account)); + slep->key(), describeOwnerDir(account), ctx_.app.journal ("View")); if (! isTesSuccess(ter)) return ter; (*slep)[sfOwnerNode] = page; @@ -337,7 +337,7 @@ SusPayFinish::doApply() auto const page = (*slep)[sfOwnerNode]; TER const ter = dirDelete(ctx_.view(), true, page, keylet::ownerDir(account).key, - k.key, false, page == 0); + k.key, false, page == 0, ctx_.app.journal ("View")); if (! isTesSuccess(ter)) return ter; } @@ -406,7 +406,7 @@ SusPayCancel::doApply() auto const page = (*slep)[sfOwnerNode]; TER const ter = dirDelete(ctx_.view(), true, page, keylet::ownerDir(account).key, - k.key, false, page == 0); + k.key, false, page == 0, ctx_.app.journal ("View")); if (! isTesSuccess(ter)) return ter; } diff --git a/src/ripple/app/tx/impl/Taker.cpp b/src/ripple/app/tx/impl/Taker.cpp index d3770e46c6..3f004a1113 100644 --- a/src/ripple/app/tx/impl/Taker.cpp +++ b/src/ripple/app/tx/impl/Taker.cpp @@ -576,7 +576,7 @@ Taker::consume_offer (Offer const& offer, Amounts const& order) STAmount Taker::get_funds (AccountID const& account, STAmount const& amount) const { - return accountFunds(view_, account, amount, fhZERO_IF_FROZEN); + return accountFunds(view_, account, amount, fhZERO_IF_FROZEN, journal_); } TER Taker::transferXRP ( @@ -594,7 +594,7 @@ TER Taker::transferXRP ( if (amount == zero) return tesSUCCESS; - return ripple::transferXRP (view_, from, to, amount); + return ripple::transferXRP (view_, from, to, amount, journal_); } TER Taker::redeemIOU ( @@ -617,7 +617,7 @@ TER Taker::redeemIOU ( if (get_funds (account, amount) <= zero) throw std::logic_error ("redeemIOU has no funds to redeem"); - auto ret = ripple::redeemIOU (view_, account, amount, issue); + auto ret = ripple::redeemIOU (view_, account, amount, issue, journal_); if (get_funds (account, amount) < zero) throw std::logic_error ("redeemIOU redeemed more funds than available"); @@ -640,7 +640,7 @@ TER Taker::issueIOU ( if (amount == zero) return tesSUCCESS; - return ripple::issueIOU (view_, account, amount, issue); + return ripple::issueIOU (view_, account, amount, issue, journal_); } // Performs funds transfers to fill the given offer and adjusts offer. diff --git a/src/ripple/app/tx/impl/Transaction.cpp b/src/ripple/app/tx/impl/Transaction.cpp index c5dd18c21f..d4e0b36978 100644 --- a/src/ripple/app/tx/impl/Transaction.cpp +++ b/src/ripple/app/tx/impl/Transaction.cpp @@ -35,6 +35,7 @@ Transaction::Transaction (STTx::ref stx, Validate validate, noexcept : mTransaction (stx) , mApp (app) + , j_ (app.journal ("Ledger")) { try { @@ -73,12 +74,12 @@ Transaction::pointer Transaction::sharedTransaction ( } catch (std::exception& e) { - WriteLog(lsWARNING, Ledger) << "Exception constructing transaction" << + JLOG (app.journal ("Ledger").warning) << "Exception constructing transaction" << e.what (); } catch (...) { - WriteLog(lsWARNING, Ledger) << "Exception constructing transaction"; + JLOG (app.journal ("Ledger").warning) << "Exception constructing transaction"; } return std::shared_ptr (); @@ -104,7 +105,7 @@ bool Transaction::checkSign (std::string& reason, SigVerify sigVerify) const else return true; - WriteLog (lsWARNING, Ledger) << reason; + JLOG (j_.warning) << reason; return false; } diff --git a/src/ripple/app/tx/impl/TransactionAcquire.cpp b/src/ripple/app/tx/impl/TransactionAcquire.cpp index 8f292aa02e..a271cb8739 100644 --- a/src/ripple/app/tx/impl/TransactionAcquire.cpp +++ b/src/ripple/app/tx/impl/TransactionAcquire.cpp @@ -41,8 +41,9 @@ enum TransactionAcquire::TransactionAcquire (Application& app, uint256 const& hash, clock_type& clock) : PeerSet (app, hash, TX_ACQUIRE_TIMEOUT, true, clock, - app.logs().journal("TransactionAcquire")) + app.journal("TransactionAcquire")) , mHaveRoot (false) + , j_(app.journal("TransactionAcquire")) { mMap = std::make_shared (SHAMapType::TRANSACTION, hash, app_.family()); @@ -59,11 +60,11 @@ void TransactionAcquire::done () if (mFailed) { - WriteLog (lsWARNING, TransactionAcquire) << "Failed to acquire TX set " << mHash; + JLOG (j_.warning) << "Failed to acquire TX set " << mHash; } else { - WriteLog (lsDEBUG, TransactionAcquire) << "Acquired TX set " << mHash; + JLOG (j_.debug) << "Acquired TX set " << mHash; mMap->setImmutable (); uint256 const& hash (mHash); @@ -110,18 +111,18 @@ void TransactionAcquire::trigger (Peer::ptr const& peer) { if (mComplete) { - WriteLog (lsINFO, TransactionAcquire) << "trigger after complete"; + JLOG (j_.info) << "trigger after complete"; return; } if (mFailed) { - WriteLog (lsINFO, TransactionAcquire) << "trigger after fail"; + JLOG (j_.info) << "trigger after fail"; return; } if (!mHaveRoot) { - WriteLog (lsTRACE, TransactionAcquire) << "TransactionAcquire::trigger " << (peer ? "havePeer" : "noPeer") << " no root"; + JLOG (j_.trace) << "TransactionAcquire::trigger " << (peer ? "havePeer" : "noPeer") << " no root"; protocol::TMGetLedger tmGL; tmGL.set_ledgerhash (mHash.begin (), mHash.size ()); tmGL.set_itype (protocol::liTS_CANDIDATE); @@ -178,13 +179,13 @@ SHAMapAddNode TransactionAcquire::takeNodes (const std::list& node if (mComplete) { - WriteLog (lsTRACE, TransactionAcquire) << "TX set complete"; + JLOG (j_.trace) << "TX set complete"; return SHAMapAddNode (); } if (mFailed) { - WriteLog (lsTRACE, TransactionAcquire) << "TX set failed"; + JLOG (j_.trace) << "TX set failed"; return SHAMapAddNode (); } @@ -202,17 +203,17 @@ SHAMapAddNode TransactionAcquire::takeNodes (const std::list& node if (nodeIDit->isRoot ()) { if (mHaveRoot) - WriteLog (lsDEBUG, TransactionAcquire) << "Got root TXS node, already have it"; + JLOG (j_.debug) << "Got root TXS node, already have it"; else if (!mMap->addRootNode (getHash (), *nodeDatait, snfWIRE, nullptr).isGood()) { - WriteLog (lsWARNING, TransactionAcquire) << "TX acquire got bad root node"; + JLOG (j_.warning) << "TX acquire got bad root node"; } else mHaveRoot = true; } else if (!mMap->addKnownNode (*nodeIDit, *nodeDatait, &sf).isGood()) { - WriteLog (lsWARNING, TransactionAcquire) << "TX acquire got bad non-root node"; + JLOG (j_.warning) << "TX acquire got bad non-root node"; return SHAMapAddNode::invalid (); } @@ -226,7 +227,7 @@ SHAMapAddNode TransactionAcquire::takeNodes (const std::list& node } catch (...) { - WriteLog (lsERROR, TransactionAcquire) << "Peer sends us junky transaction node data"; + JLOG (j_.error) << "Peer sends us junky transaction node data"; return SHAMapAddNode::invalid (); } } diff --git a/src/ripple/app/tx/impl/TransactionMaster.cpp b/src/ripple/app/tx/impl/TransactionMaster.cpp index b382dec051..98bd047e02 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(), - mApp.logs().journal("TaggedCache")) + mApp.journal("TaggedCache")) { } diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index 346e67fc17..9aaca259c7 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -454,7 +454,8 @@ TER Transactor::checkMultiSign () //------------------------------------------------------------------------------ -void removeUnfundedOffers (ApplyView& view, std::vector const& offers) +static +void removeUnfundedOffers (ApplyView& view, std::vector const& offers, beast::Journal viewJ) { int removed = 0; @@ -464,7 +465,7 @@ void removeUnfundedOffers (ApplyView& view, std::vector const& offers) if (sleOffer) { // offer is unfunded - offerDelete (view, sleOffer); + offerDelete (view, sleOffer, viewJ); if (++removed == 1000) return; } @@ -620,7 +621,7 @@ Transactor::operator()() txnAcct->setFieldU32 (sfSequence, t_seq + 1); if (terResult == tecOVERSIZE) - removeUnfundedOffers (view(), removedOffers); + removeUnfundedOffers (view(), removedOffers, ctx_.app.journal ("View")); view().update (txnAcct); didApply = true; diff --git a/src/ripple/core/Config.h b/src/ripple/core/Config.h index b1e08433f7..e15fd6b657 100644 --- a/src/ripple/core/Config.h +++ b/src/ripple/core/Config.h @@ -29,6 +29,7 @@ #include #include #include +#include #include // VFALCO FIX: This include should not be here #include // VFALCO FIX: This include should not be here #include @@ -47,7 +48,7 @@ parseIniFile (std::string const& strInput, const bool bTrim); bool getSingleSection (IniFileSections& secSource, - std::string const& strSection, std::string& strValue); + std::string const& strSection, std::string& strValue, beast::Journal j); int countSectionEntries (IniFileSections& secSource, std::string const& strSection); @@ -131,6 +132,7 @@ private: boost::filesystem::path DEBUG_LOGFILE; void load (); + beast::Journal j_; public: //-------------------------------------------------------------------------- diff --git a/src/ripple/core/DatabaseCon.h b/src/ripple/core/DatabaseCon.h index 205afbe125..b194784337 100644 --- a/src/ripple/core/DatabaseCon.h +++ b/src/ripple/core/DatabaseCon.h @@ -99,7 +99,7 @@ public: return LockedSociSession (&session_, lock_); } - void setupCheckpointing (JobQueue*); + void setupCheckpointing (JobQueue*, Logs&); private: LockedSociSession::mutex lock_; diff --git a/src/ripple/core/JobQueue.h b/src/ripple/core/JobQueue.h index 1968a97863..b7e55a6f79 100644 --- a/src/ripple/core/JobQueue.h +++ b/src/ripple/core/JobQueue.h @@ -30,6 +30,8 @@ namespace ripple { +class Logs; + class JobQueue : public beast::Stoppable { protected: @@ -82,7 +84,7 @@ public: std::unique_ptr make_JobQueue (beast::insight::Collector::ptr const& collector, - beast::Stoppable& parent, beast::Journal journal); + beast::Stoppable& parent, beast::Journal journal, Logs& logs); } diff --git a/src/ripple/core/JobTypeData.h b/src/ripple/core/JobTypeData.h index 105f95037a..1aa78b5990 100644 --- a/src/ripple/core/JobTypeData.h +++ b/src/ripple/core/JobTypeData.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_CORE_JOBTYPEDATA_H_INCLUDED #define RIPPLE_CORE_JOBTYPEDATA_H_INCLUDED +#include #include namespace ripple @@ -50,9 +51,10 @@ public: beast::insight::Event dequeue; beast::insight::Event execute; - explicit JobTypeData (JobTypeInfo const& info_, - beast::insight::Collector::ptr const& collector) noexcept - : m_collector (collector) + JobTypeData (JobTypeInfo const& info_, + beast::insight::Collector::ptr const& collector, Logs& logs) noexcept + : m_load (logs.journal ("LoadMonitor")) + , m_collector (collector) , info (info_) , waiting (0) , running (0) diff --git a/src/ripple/core/LoadMonitor.h b/src/ripple/core/LoadMonitor.h index 4da2d4bfca..1a5f2e240f 100644 --- a/src/ripple/core/LoadMonitor.h +++ b/src/ripple/core/LoadMonitor.h @@ -21,6 +21,7 @@ #define RIPPLE_CORE_LOADMONITOR_H_INCLUDED #include +#include #include #include @@ -33,7 +34,8 @@ namespace ripple { class LoadMonitor { public: - LoadMonitor (); + explicit + LoadMonitor (beast::Journal j); void addCount (); @@ -78,6 +80,7 @@ private: std::uint64_t mTargetLatencyAvg; std::uint64_t mTargetLatencyPk; int mLastUpdate; + beast::Journal j_; }; } // ripple diff --git a/src/ripple/core/SociDB.h b/src/ripple/core/SociDB.h index 431394db1b..5d6c565aa9 100644 --- a/src/ripple/core/SociDB.h +++ b/src/ripple/core/SociDB.h @@ -128,7 +128,7 @@ class Checkpointer The Checkpointer contains references to the session and job queue and so must outlive them both. */ -std::unique_ptr makeCheckpointer (soci::session&, JobQueue&); +std::unique_ptr makeCheckpointer (soci::session&, JobQueue&, Logs&); } // ripple diff --git a/src/ripple/core/impl/Config.cpp b/src/ripple/core/impl/Config.cpp index dae8ac0044..149e828e4d 100644 --- a/src/ripple/core/impl/Config.cpp +++ b/src/ripple/core/impl/Config.cpp @@ -118,7 +118,7 @@ countSectionEntries (IniFileSections& secSource, std::string const& strSection) } bool getSingleSection (IniFileSections& secSource, - std::string const& strSection, std::string& strValue) + std::string const& strSection, std::string& strValue, beast::Journal j) { IniFileSections::mapped_type* pmtEntries = getIniFileSection (secSource, strSection); @@ -130,9 +130,9 @@ bool getSingleSection (IniFileSections& secSource, } else if (pmtEntries) { - WriteLog (lsWARNING, parseIniFile) << boost::str (boost::format ("Section [%s]: requires 1 line not %d lines.") - % strSection - % pmtEntries->size ()); + JLOG (j.warning) << boost::str ( + boost::format ("Section [%s]: requires 1 line not %d lines.") % + strSection % pmtEntries->size ()); } return bSingle; @@ -359,7 +359,7 @@ void Config::loadFromString (std::string const& fileContents) { std::string dbPath; - if (getSingleSection (secConfig, "database_path", dbPath)) + if (getSingleSection (secConfig, "database_path", dbPath, j_)) { boost::filesystem::path p(dbPath); legacy("database_path", @@ -367,16 +367,16 @@ void Config::loadFromString (std::string const& fileContents) } } - (void) getSingleSection (secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE); + (void) getSingleSection (secConfig, SECTION_VALIDATORS_SITE, VALIDATORS_SITE, j_); std::string strTemp; - if (getSingleSection (secConfig, SECTION_PEER_PRIVATE, strTemp)) + if (getSingleSection (secConfig, SECTION_PEER_PRIVATE, strTemp, j_)) PEER_PRIVATE = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_PEERS_MAX, strTemp)) + if (getSingleSection (secConfig, SECTION_PEERS_MAX, strTemp, j_)) PEERS_MAX = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_NODE_SIZE, strTemp)) + if (getSingleSection (secConfig, SECTION_NODE_SIZE, strTemp, j_)) { if (strTemp == "tiny") NODE_SIZE = 0; @@ -399,19 +399,19 @@ void Config::loadFromString (std::string const& fileContents) } } - if (getSingleSection (secConfig, SECTION_ELB_SUPPORT, strTemp)) + if (getSingleSection (secConfig, SECTION_ELB_SUPPORT, strTemp, j_)) ELB_SUPPORT = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp)) + if (getSingleSection (secConfig, SECTION_WEBSOCKET_PING_FREQ, strTemp, j_)) WEBSOCKET_PING_FREQ = beast::lexicalCastThrow (strTemp); - getSingleSection (secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE); - getSingleSection (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR); + getSingleSection (secConfig, SECTION_SSL_VERIFY_FILE, SSL_VERIFY_FILE, j_); + getSingleSection (secConfig, SECTION_SSL_VERIFY_DIR, SSL_VERIFY_DIR, j_); - if (getSingleSection (secConfig, SECTION_SSL_VERIFY, strTemp)) + if (getSingleSection (secConfig, SECTION_SSL_VERIFY, strTemp, j_)) SSL_VERIFY = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_VALIDATION_SEED, strTemp)) + if (getSingleSection (secConfig, SECTION_VALIDATION_SEED, strTemp, j_)) { VALIDATION_SEED.setSeedGeneric (strTemp); @@ -422,7 +422,7 @@ void Config::loadFromString (std::string const& fileContents) } } - if (getSingleSection (secConfig, SECTION_NODE_SEED, strTemp)) + if (getSingleSection (secConfig, SECTION_NODE_SEED, strTemp, j_)) { NODE_SEED.setSeedGeneric (strTemp); @@ -433,25 +433,25 @@ void Config::loadFromString (std::string const& fileContents) } } - if (getSingleSection (secConfig, SECTION_NETWORK_QUORUM, strTemp)) + if (getSingleSection (secConfig, SECTION_NETWORK_QUORUM, strTemp, j_)) NETWORK_QUORUM = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_VALIDATION_QUORUM, strTemp)) + if (getSingleSection (secConfig, SECTION_VALIDATION_QUORUM, strTemp, j_)) VALIDATION_QUORUM = std::max (0, beast::lexicalCastThrow (strTemp)); - if (getSingleSection (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp)) + if (getSingleSection (secConfig, SECTION_FEE_ACCOUNT_RESERVE, strTemp, j_)) FEE_ACCOUNT_RESERVE = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp)) + if (getSingleSection (secConfig, SECTION_FEE_OWNER_RESERVE, strTemp, j_)) FEE_OWNER_RESERVE = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_FEE_OFFER, strTemp)) + if (getSingleSection (secConfig, SECTION_FEE_OFFER, strTemp, j_)) FEE_OFFER = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_FEE_DEFAULT, strTemp)) + if (getSingleSection (secConfig, SECTION_FEE_DEFAULT, strTemp, j_)) FEE_DEFAULT = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_LEDGER_HISTORY, strTemp)) + if (getSingleSection (secConfig, SECTION_LEDGER_HISTORY, strTemp, j_)) { boost::to_lower (strTemp); @@ -463,7 +463,7 @@ void Config::loadFromString (std::string const& fileContents) LEDGER_HISTORY = beast::lexicalCastThrow (strTemp); } - if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp)) + if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp, j_)) { boost::to_lower (strTemp); @@ -478,21 +478,21 @@ void Config::loadFromString (std::string const& fileContents) FETCH_DEPTH = 10; } - if (getSingleSection (secConfig, SECTION_PATH_SEARCH_OLD, strTemp)) + if (getSingleSection (secConfig, SECTION_PATH_SEARCH_OLD, strTemp, j_)) PATH_SEARCH_OLD = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_PATH_SEARCH, strTemp)) + if (getSingleSection (secConfig, SECTION_PATH_SEARCH, strTemp, j_)) PATH_SEARCH = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_PATH_SEARCH_FAST, strTemp)) + if (getSingleSection (secConfig, SECTION_PATH_SEARCH_FAST, strTemp, j_)) PATH_SEARCH_FAST = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_PATH_SEARCH_MAX, strTemp)) + if (getSingleSection (secConfig, SECTION_PATH_SEARCH_MAX, strTemp, j_)) PATH_SEARCH_MAX = beast::lexicalCastThrow (strTemp); - if (getSingleSection (secConfig, SECTION_VALIDATORS_FILE, strTemp)) + if (getSingleSection (secConfig, SECTION_VALIDATORS_FILE, strTemp, j_)) { VALIDATORS_FILE = strTemp; } - if (getSingleSection (secConfig, SECTION_DEBUG_LOGFILE, strTemp)) + if (getSingleSection (secConfig, SECTION_DEBUG_LOGFILE, strTemp, j_)) DEBUG_LOGFILE = strTemp; { diff --git a/src/ripple/core/impl/DatabaseCon.cpp b/src/ripple/core/impl/DatabaseCon.cpp index b8ce18d407..eee19c2b27 100644 --- a/src/ripple/core/impl/DatabaseCon.cpp +++ b/src/ripple/core/impl/DatabaseCon.cpp @@ -65,11 +65,11 @@ DatabaseCon::Setup setup_DatabaseCon (Config const& c) return setup; } -void DatabaseCon::setupCheckpointing (JobQueue* q) +void DatabaseCon::setupCheckpointing (JobQueue* q, Logs& l) { if (! q) throw std::logic_error ("No JobQueue"); - checkpointer_ = makeCheckpointer (session_, *q); + checkpointer_ = makeCheckpointer (session_, *q, l); } } // ripple diff --git a/src/ripple/core/impl/JobQueue.cpp b/src/ripple/core/impl/JobQueue.cpp index e5c0bea74d..a547cf2624 100644 --- a/src/ripple/core/impl/JobQueue.cpp +++ b/src/ripple/core/impl/JobQueue.cpp @@ -72,11 +72,11 @@ public: //-------------------------------------------------------------------------- JobQueueImp (beast::insight::Collector::ptr const& collector, - Stoppable& parent, beast::Journal journal) + Stoppable& parent, beast::Journal journal, Logs& logs) : JobQueue ("JobQueue", parent) , m_journal (journal) , m_lastJob (0) - , m_invalidJobData (getJobTypes ().getInvalid (), collector) + , m_invalidJobData (getJobTypes ().getInvalid (), collector, logs) , m_processCount (0) , m_workers (*this, "JobQueue", 0) , m_cancelCallback (std::bind (&Stoppable::isStopping, this)) @@ -96,7 +96,7 @@ public: // And create dynamic information for all jobs auto const result (m_jobData.emplace (std::piecewise_construct, std::forward_as_tuple (jt.type ()), - std::forward_as_tuple (jt, m_collector))); + std::forward_as_tuple (jt, m_collector, logs))); assert (result.second == true); (void) result.second; } @@ -695,9 +695,9 @@ JobQueue::JobQueue (char const* name, Stoppable& parent) std::unique_ptr make_JobQueue ( beast::insight::Collector::ptr const& collector, - beast::Stoppable& parent, beast::Journal journal) + beast::Stoppable& parent, beast::Journal journal, Logs& logs) { - return std::make_unique (collector, parent, journal); + return std::make_unique (collector, parent, journal, logs); } } diff --git a/src/ripple/core/impl/LoadMonitor.cpp b/src/ripple/core/impl/LoadMonitor.cpp index dc39c5a201..478521bca0 100644 --- a/src/ripple/core/impl/LoadMonitor.cpp +++ b/src/ripple/core/impl/LoadMonitor.cpp @@ -45,7 +45,7 @@ LoadMonitor::Stats::Stats() //------------------------------------------------------------------------------ -LoadMonitor::LoadMonitor () +LoadMonitor::LoadMonitor (beast::Journal j) : mCounts (0) , mLatencyEvents (0) , mLatencyMSAvg (0) @@ -53,6 +53,7 @@ LoadMonitor::LoadMonitor () , mTargetLatencyAvg (0) , mTargetLatencyPk (0) , mLastUpdate (UptimeTimer::getInstance ().getElapsedSeconds ()) + , j_ (j) { } @@ -146,7 +147,8 @@ void LoadMonitor::addLoadSample (LoadEvent const& sample) if (latency.inSeconds() > 0.5) { - WriteLog ((latency.inSeconds() > 1.0) ? lsWARNING : lsINFO, LoadMonitor) + auto& mj = latency.inSeconds() > 1.0 ? j_.warning : j_.info; + JLOG (mj) << "Job: " << name << " ExecutionTime: " << printElapsed (sample.getSecondsRunning()) << " WaitingTime: " << printElapsed (sample.getSecondsWaiting()); } diff --git a/src/ripple/core/impl/SociDB.cpp b/src/ripple/core/impl/SociDB.cpp index b13f94875b..dd33e6e6f2 100644 --- a/src/ripple/core/impl/SociDB.cpp +++ b/src/ripple/core/impl/SociDB.cpp @@ -185,8 +185,8 @@ namespace { class WALCheckpointer : public Checkpointer { public: - WALCheckpointer (sqlite_api::sqlite3& conn, JobQueue& q) - : conn_ (conn), jobQueue_ (q) + WALCheckpointer (sqlite_api::sqlite3& conn, JobQueue& q, Logs& logs) + : conn_ (conn), jobQueue_ (q), j_ (logs.journal ("WALCheckpointer")) { sqlite_api::sqlite3_wal_hook (&conn_, &sqliteWALHook, this); } @@ -199,6 +199,7 @@ private: JobQueue& jobQueue_; bool running_ = false; + beast::Journal j_; static int sqliteWALHook ( @@ -235,13 +236,13 @@ private: auto fname = sqlite3_db_filename (&conn_, "main"); if (ret != SQLITE_OK) { - WriteLog ((ret == SQLITE_LOCKED) ? lsTRACE : lsWARNING, - WALCheckpointer) + auto& jm = (ret == SQLITE_LOCKED) ? j_.trace : j_.warning; + JLOG (jm) << "WAL(" << fname << "): error " << ret; } else { - WriteLog (lsTRACE, WALCheckpointer) + JLOG (j_.trace) << "WAL(" << fname << "): frames=" << log << ", written=" << ckpt; } @@ -254,10 +255,10 @@ private: } // namespace std::unique_ptr makeCheckpointer ( - soci::session& session, JobQueue& queue) + soci::session& session, JobQueue& queue, Logs& logs) { if (auto conn = getConnection (session)) - return std::make_unique (*conn, queue); + return std::make_unique (*conn, queue, logs); return {}; } diff --git a/src/ripple/ledger/ApplyView.h b/src/ripple/ledger/ApplyView.h index 0d96b1e9d5..c788c41d76 100644 --- a/src/ripple/ledger/ApplyView.h +++ b/src/ripple/ledger/ApplyView.h @@ -109,6 +109,9 @@ class ApplyView : public ReadView { public: + + ApplyView () = default; + /** Returns the tx apply flags. Flags can affect the outcome of transaction diff --git a/src/ripple/ledger/ReadView.h b/src/ripple/ledger/ReadView.h index 781a562f0b..be8f277f95 100644 --- a/src/ripple/ledger/ReadView.h +++ b/src/ripple/ledger/ReadView.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -208,13 +209,13 @@ public: ReadView& operator= (ReadView&& other) = delete; ReadView& operator= (ReadView const& other) = delete; - ReadView() + ReadView () : sles(*this) , txs(*this) { } - ReadView (ReadView const&) + ReadView (ReadView const& other) : sles(*this) , txs(*this) { @@ -393,6 +394,9 @@ class DigestAwareReadView public: using digest_type = uint256; + DigestAwareReadView () = default; + DigestAwareReadView (const DigestAwareReadView&) = default; + /** Return the digest associated with the key. @return boost::none if the item does not exist. diff --git a/src/ripple/ledger/TxMeta.h b/src/ripple/ledger/TxMeta.h index f41f070b18..889d7c6b3f 100644 --- a/src/ripple/ledger/TxMeta.h +++ b/src/ripple/ledger/TxMeta.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -38,27 +39,29 @@ public: private: struct CtorHelper{}; template - TxMeta (uint256 const& txID, std::uint32_t ledger, T const& data, + TxMeta (uint256 const& txID, std::uint32_t ledger, T const& data, beast::Journal j, CtorHelper); public: - TxMeta () + TxMeta (beast::Journal j) : mLedger (0) , mIndex (static_cast (-1)) , mResult (255) + , j_ (j) { } - TxMeta (uint256 const& txID, std::uint32_t ledger, std::uint32_t index) + TxMeta (uint256 const& txID, std::uint32_t ledger, std::uint32_t index, beast::Journal j) : mTransactionID (txID) , mLedger (ledger) , mIndex (static_cast (-1)) , mResult (255) + , j_(j) { } - TxMeta (uint256 const& txID, std::uint32_t ledger, Blob const&); - TxMeta (uint256 const& txID, std::uint32_t ledger, std::string const&); - TxMeta (uint256 const& txID, std::uint32_t ledger, STObject const&); + TxMeta (uint256 const& txID, std::uint32_t ledger, Blob const&, beast::Journal j); + TxMeta (uint256 const& txID, std::uint32_t ledger, std::string const&, beast::Journal j); + TxMeta (uint256 const& txID, std::uint32_t ledger, STObject const&, beast::Journal j); void init (uint256 const& transactionID, std::uint32_t ledger); void clear () @@ -138,6 +141,8 @@ private: boost::optional mDelivered; STArray mNodes; + + beast::Journal j_; }; } // ripple diff --git a/src/ripple/ledger/View.h b/src/ripple/ledger/View.h index 2a58d112f8..598ac835bc 100644 --- a/src/ripple/ledger/View.h +++ b/src/ripple/ledger/View.h @@ -65,11 +65,13 @@ isGlobalFrozen (ReadView const& view, STAmount accountHolds (ReadView const& view, AccountID const& account, Currency const& currency, - AccountID const& issuer, FreezeHandling zeroIfFrozen); + AccountID const& issuer, FreezeHandling zeroIfFrozen, + beast::Journal j); STAmount accountFunds (ReadView const& view, AccountID const& id, - STAmount const& saDefault, FreezeHandling freezeHandling); + STAmount const& saDefault, FreezeHandling freezeHandling, + beast::Journal j); /** Iterate all items in an account's owner directory. */ void @@ -113,7 +115,8 @@ cdirFirst (ReadView const& view, uint256 const& uRootIndex, // --> Root of directory. std::shared_ptr& sleNode, // <-> current node unsigned int& uDirEntry, // <-- next entry - uint256& uEntryIndex); // <-- The entry, if available. Otherwise, zero. + uint256& uEntryIndex, // <-- The entry, if available. Otherwise, zero. + beast::Journal j); // Return the current entry and advance uDirEntry. // <-- true, if had a next entry. @@ -123,7 +126,8 @@ cdirNext (ReadView const& view, uint256 const& uRootIndex, // --> Root of directory std::shared_ptr& sleNode, // <-> current node unsigned int& uDirEntry, // <-> next entry - uint256& uEntryIndex); // <-- The entry, if available. Otherwise, zero. + uint256& uEntryIndex, // <-- The entry, if available. Otherwise, zero. + beast::Journal j); // Return the list of enabled amendments using enabledAmendments_t = std::set ; @@ -188,7 +192,7 @@ bool areCompatible (uint256 const& validHash, LedgerIndex validIndex, void adjustOwnerCount (ApplyView& view, std::shared_ptr const& sle, - int amount); + int amount, beast::Journal j); // Return the first entry and advance uDirEntry. // <-- true, if had a next entry. @@ -198,7 +202,8 @@ dirFirst (ApplyView& view, uint256 const& uRootIndex, // --> Root of directory. std::shared_ptr& sleNode, // <-> current node unsigned int& uDirEntry, // <-- next entry - uint256& uEntryIndex); // <-- The entry, if available. Otherwise, zero. + uint256& uEntryIndex, // <-- The entry, if available. Otherwise, zero. + beast::Journal j); // Return the current entry and advance uDirEntry. // <-- true, if had a next entry. @@ -208,7 +213,8 @@ dirNext (ApplyView& view, uint256 const& uRootIndex, // --> Root of directory std::shared_ptr& sleNode, // <-> current node unsigned int& uDirEntry, // <-> next entry - uint256& uEntryIndex); // <-- The entry, if available. Otherwise, zero. + uint256& uEntryIndex, // <-- The entry, if available. Otherwise, zero. + beast::Journal j); std::function describeOwnerDir(AccountID const& account); @@ -223,7 +229,8 @@ dirAdd (ApplyView& view, std::uint64_t& uNodeDir, // Node of entry. uint256 const& uRootIndex, uint256 const& uLedgerIndex, - std::function fDescriber); + std::function fDescriber, + beast::Journal j); TER dirDelete (ApplyView& view, @@ -232,7 +239,8 @@ dirDelete (ApplyView& view, uint256 const& uRootIndex, uint256 const& uLedgerIndex, // Item being deleted const bool bStable, - const bool bSoft); + const bool bSoft, + beast::Journal j); // VFALCO NOTE Both STAmount parameters should just // be "Amount", a unit-less number. @@ -256,13 +264,15 @@ trustCreate (ApplyView& view, STAmount const& saLimit, // --> limit for account being set. // Issuer should be the account being set. std::uint32_t uSrcQualityIn, - std::uint32_t uSrcQualityOut); + std::uint32_t uSrcQualityOut, + beast::Journal j); TER trustDelete (ApplyView& view, std::shared_ptr const& sleRippleState, AccountID const& uLowAccountID, - AccountID const& uHighAccountID); + AccountID const& uHighAccountID, + beast::Journal j); /** Delete an offer. @@ -272,7 +282,8 @@ trustDelete (ApplyView& view, */ TER offerDelete (ApplyView& view, - std::shared_ptr const& sle); + std::shared_ptr const& sle, + beast::Journal j); //------------------------------------------------------------------------------ @@ -287,31 +298,36 @@ offerDelete (ApplyView& view, TER rippleCredit (ApplyView& view, AccountID const& uSenderID, AccountID const& uReceiverID, - const STAmount & saAmount, bool bCheckIssuer); + const STAmount & saAmount, bool bCheckIssuer, + beast::Journal j); TER accountSend (ApplyView& view, AccountID const& from, AccountID const& to, - const STAmount & saAmount); + const STAmount & saAmount, + beast::Journal j); TER issueIOU (ApplyView& view, AccountID const& account, STAmount const& amount, - Issue const& issue); + Issue const& issue, + beast::Journal j); TER redeemIOU (ApplyView& view, AccountID const& account, STAmount const& amount, - Issue const& issue); + Issue const& issue, + beast::Journal j); TER transferXRP (ApplyView& view, AccountID const& from, AccountID const& to, - STAmount const& amount); + STAmount const& amount, + beast::Journal j); } // ripple diff --git a/src/ripple/ledger/impl/ApplyStateTable.cpp b/src/ripple/ledger/impl/ApplyStateTable.cpp index 876810071b..d4ca9cfd99 100644 --- a/src/ripple/ledger/impl/ApplyStateTable.cpp +++ b/src/ripple/ledger/impl/ApplyStateTable.cpp @@ -118,7 +118,7 @@ ApplyStateTable::apply (OpenView& to, std::shared_ptr sMeta; if (to.closed()) { - TxMeta meta; + TxMeta meta(j); // VFALCO Shouldn't TxMeta ctor do this? meta.init (tx.getTransactionID(), to.seq()); if (deliver) diff --git a/src/ripple/ledger/impl/TxMeta.cpp b/src/ripple/ledger/impl/TxMeta.cpp index 45c43c3808..af929b77b8 100644 --- a/src/ripple/ledger/impl/TxMeta.cpp +++ b/src/ripple/ledger/impl/TxMeta.cpp @@ -30,10 +30,11 @@ namespace ripple { template TxMeta::TxMeta (uint256 const& txid, - std::uint32_t ledger, T const& data, CtorHelper) + std::uint32_t ledger, T const& data, beast::Journal j, CtorHelper) : mTransactionID (txid) , mLedger (ledger) , mNodes (sfAffectedNodes, 32) + , j_ (j) { SerialIter sit (makeSlice(data)); @@ -46,10 +47,12 @@ TxMeta::TxMeta (uint256 const& txid, setDeliveredAmount (obj.getFieldAmount (sfDeliveredAmount)); } -TxMeta::TxMeta (uint256 const& txid, std::uint32_t ledger, STObject const& obj) +TxMeta::TxMeta (uint256 const& txid, std::uint32_t ledger, STObject const& obj, + beast::Journal j) : mTransactionID (txid) , mLedger (ledger) , mNodes (obj.getFieldArray (sfAffectedNodes)) + , j_ (j) { mResult = obj.getFieldU8 (sfTransactionResult); mIndex = obj.getFieldU32 (sfTransactionIndex); @@ -65,16 +68,18 @@ TxMeta::TxMeta (uint256 const& txid, std::uint32_t ledger, STObject const& obj) } TxMeta::TxMeta (uint256 const& txid, - std::uint32_t ledger, - Blob const& vec) - : TxMeta (txid, ledger, vec, CtorHelper ()) + std::uint32_t ledger, + Blob const& vec, + beast::Journal j) + : TxMeta (txid, ledger, vec, j, CtorHelper ()) { } TxMeta::TxMeta (uint256 const& txid, - std::uint32_t ledger, - std::string const& data) - : TxMeta (txid, ledger, data, CtorHelper ()) + std::uint32_t ledger, + std::string const& data, + beast::Journal j) + : TxMeta (txid, ledger, data, j, CtorHelper ()) { } @@ -155,7 +160,7 @@ TxMeta::getAffectedAccounts() const } else { - WriteLog (lsFATAL, TxMeta) << "limit is not amount " << field.getJson (0); + JLOG (j_.fatal) << "limit is not amount " << field.getJson (0); } } } diff --git a/src/ripple/ledger/impl/View.cpp b/src/ripple/ledger/impl/View.cpp index 1e393ed0a6..337bd74ea1 100644 --- a/src/ripple/ledger/impl/View.cpp +++ b/src/ripple/ledger/impl/View.cpp @@ -100,7 +100,8 @@ isFrozen (ReadView const& view, AccountID const& account, STAmount accountHolds (ReadView const& view, AccountID const& account, Currency const& currency, - AccountID const& issuer, FreezeHandling zeroIfFrozen) + AccountID const& issuer, FreezeHandling zeroIfFrozen, + beast::Journal j) { STAmount amount; if (isXRP(currency)) @@ -117,7 +118,7 @@ accountHolds (ReadView const& view, amount.clear (); else amount = balance - reserve; - WriteLog (lsTRACE, View) << "accountHolds:" << + JLOG (j.trace) << "accountHolds:" << " account=" << to_string (account) << " amount=" << amount.getFullText () << " balance=" << to_string (balance) << @@ -147,7 +148,7 @@ accountHolds (ReadView const& view, } amount.setIssuer (issuer); } - WriteLog (lsTRACE, View) << "accountHolds:" << + JLOG (j.trace) << "accountHolds:" << " account=" << to_string (account) << " amount=" << amount.getFullText (); } @@ -158,7 +159,8 @@ accountHolds (ReadView const& view, STAmount accountFunds (ReadView const& view, AccountID const& id, - STAmount const& saDefault, FreezeHandling freezeHandling) + STAmount const& saDefault, FreezeHandling freezeHandling, + beast::Journal j) { STAmount saFunds; @@ -166,7 +168,7 @@ accountFunds (ReadView const& view, AccountID const& id, saDefault.getIssuer () == id) { saFunds = saDefault; - WriteLog (lsTRACE, View) << "accountFunds:" << + JLOG (j.trace) << "accountFunds:" << " account=" << to_string (id) << " saDefault=" << saDefault.getFullText () << " SELF-FUNDED"; @@ -175,8 +177,8 @@ accountFunds (ReadView const& view, AccountID const& id, { saFunds = accountHolds(view, id, saDefault.getCurrency(), saDefault.getIssuer(), - freezeHandling); - WriteLog (lsTRACE, View) << "accountFunds:" << + freezeHandling, j); + JLOG (j.trace) << "accountFunds:" << " account=" << to_string (id) << " saDefault=" << saDefault.getFullText () << " saFunds=" << saFunds.getFullText (); @@ -416,12 +418,13 @@ cdirFirst (ReadView const& view, uint256 const& uRootIndex, // --> Root of directory. std::shared_ptr& sleNode, // <-> current node unsigned int& uDirEntry, // <-- next entry - uint256& uEntryIndex) // <-- The entry, if available. Otherwise, zero. + uint256& uEntryIndex, // <-- The entry, if available. Otherwise, zero. + beast::Journal j) { sleNode = view.read(keylet::page(uRootIndex)); uDirEntry = 0; assert (sleNode); // Never probe for directories. - return cdirNext (view, uRootIndex, sleNode, uDirEntry, uEntryIndex); + return cdirNext (view, uRootIndex, sleNode, uDirEntry, uEntryIndex, j); } bool @@ -429,7 +432,8 @@ cdirNext (ReadView const& view, uint256 const& uRootIndex, // --> Root of directory std::shared_ptr& sleNode, // <-> current node unsigned int& uDirEntry, // <-> next entry - uint256& uEntryIndex) // <-- The entry, if available. Otherwise, zero. + uint256& uEntryIndex, // <-- The entry, if available. Otherwise, zero. + beast::Journal j) { auto const& svIndexes = sleNode->getFieldV256 (sfIndexes); assert (uDirEntry <= svIndexes.size ()); @@ -448,17 +452,17 @@ cdirNext (ReadView const& view, if (!sleNext) { // This should never happen - WriteLog (lsFATAL, View) + JLOG (j.fatal) << "Corrupt directory: index:" << uRootIndex << " next:" << uNodeNext; return false; } sleNode = sleNext; return cdirNext (view, uRootIndex, - sleNode, uDirEntry, uEntryIndex); + sleNode, uDirEntry, uEntryIndex, j); } uEntryIndex = svIndexes[uDirEntry++]; - WriteLog (lsTRACE, View) << "dirNext:" << + JLOG (j.trace) << "dirNext:" << " uDirEntry=" << uDirEntry << " uEntryIndex=" << uEntryIndex; return true; @@ -576,7 +580,7 @@ hashOfSeq (ReadView const& ledger, LedgerIndex seq, void adjustOwnerCount (ApplyView& view, std::shared_ptr const& sle, - int amount) + int amount, beast::Journal j) { assert(amount != 0); auto const current = @@ -587,7 +591,7 @@ adjustOwnerCount (ApplyView& view, // Overflow is well defined on unsigned if (adjusted < current) { - WriteLog (lsFATAL, View) << + JLOG (j.fatal) << "Account " << sle->getAccountID(sfAccount) << " owner count exceeds max!"; adjusted = @@ -599,7 +603,7 @@ adjustOwnerCount (ApplyView& view, // Underflow is well defined on unsigned if (adjusted > current) { - WriteLog (lsFATAL, View) << + JLOG (j.fatal) << "Account " << sle->getAccountID (sfAccount) << " owner count set below 0!"; adjusted = 0; @@ -615,12 +619,13 @@ dirFirst (ApplyView& view, uint256 const& uRootIndex, // --> Root of directory. std::shared_ptr& sleNode, // <-> current node unsigned int& uDirEntry, // <-- next entry - uint256& uEntryIndex) // <-- The entry, if available. Otherwise, zero. + uint256& uEntryIndex, // <-- The entry, if available. Otherwise, zero. + beast::Journal j) { sleNode = view.peek(keylet::page(uRootIndex)); uDirEntry = 0; assert (sleNode); // Never probe for directories. - return dirNext (view, uRootIndex, sleNode, uDirEntry, uEntryIndex); + return dirNext (view, uRootIndex, sleNode, uDirEntry, uEntryIndex, j); } bool @@ -628,7 +633,8 @@ dirNext (ApplyView& view, uint256 const& uRootIndex, // --> Root of directory std::shared_ptr& sleNode, // <-> current node unsigned int& uDirEntry, // <-> next entry - uint256& uEntryIndex) // <-- The entry, if available. Otherwise, zero. + uint256& uEntryIndex, // <-- The entry, if available. Otherwise, zero. + beast::Journal j) { auto const& svIndexes = sleNode->getFieldV256 (sfIndexes); assert (uDirEntry <= svIndexes.size ()); @@ -647,17 +653,17 @@ dirNext (ApplyView& view, if (!sleNext) { // This should never happen - WriteLog (lsFATAL, View) + JLOG (j.fatal) << "Corrupt directory: index:" << uRootIndex << " next:" << uNodeNext; return false; } sleNode = sleNext; return dirNext (view, uRootIndex, - sleNode, uDirEntry, uEntryIndex); + sleNode, uDirEntry, uEntryIndex, j); } uEntryIndex = svIndexes[uDirEntry++]; - WriteLog (lsTRACE, View) << "dirNext:" << + JLOG (j.trace) << "dirNext:" << " uDirEntry=" << uDirEntry << " uEntryIndex=" << uEntryIndex; return true; @@ -677,9 +683,10 @@ dirAdd (ApplyView& view, std::uint64_t& uNodeDir, uint256 const& uRootIndex, // VFALCO Should be Keylet uint256 const& uLedgerIndex, - std::function fDescriber) + std::function fDescriber, + beast::Journal j) { - WriteLog (lsTRACE, View) << "dirAdd:" << + JLOG (j.trace) << "dirAdd:" << " uRootIndex=" << to_string (uRootIndex) << " uLedgerIndex=" << to_string (uLedgerIndex); @@ -755,11 +762,11 @@ dirAdd (ApplyView& view, svIndexes.push_back (uLedgerIndex); // Append entry. sleNode->setFieldV256 (sfIndexes, svIndexes); // Save entry. - WriteLog (lsTRACE, View) << + JLOG (j.trace) << "dirAdd: creating: root: " << to_string (uRootIndex); - WriteLog (lsTRACE, View) << + JLOG (j.trace) << "dirAdd: appending: Entry: " << to_string (uLedgerIndex); - WriteLog (lsTRACE, View) << + JLOG (j.trace) << "dirAdd: appending: Node: " << strHex (uNodeDir); return tesSUCCESS; @@ -773,7 +780,8 @@ dirDelete (ApplyView& view, uint256 const& uRootIndex, // --> The index of the base of the directory. Nodes are based off of this. uint256 const& uLedgerIndex, // --> Value to remove from directory. const bool bStable, // --> True, not to change relative order of entries. - const bool bSoft) // --> True, uNodeDir is not hard and fast (pass uNodeDir=0). + const bool bSoft, // --> True, uNodeDir is not hard and fast (pass uNodeDir=0). + beast::Journal j) { std::uint64_t uNodeCur = uNodeDir; SLE::pointer sleNode = @@ -781,7 +789,7 @@ dirDelete (ApplyView& view, if (!sleNode) { - WriteLog (lsWARNING, View) << "dirDelete: no such node:" << + JLOG (j.warning) << "dirDelete: no such node:" << " uRootIndex=" << to_string (uRootIndex) << " uNodeDir=" << strHex (uNodeDir) << " uLedgerIndex=" << to_string (uLedgerIndex); @@ -796,7 +804,7 @@ dirDelete (ApplyView& view, // Go the extra mile. Even if node doesn't exist, try the next node. return dirDelete (view, bKeepRoot, - uNodeDir + 1, uRootIndex, uLedgerIndex, bStable, true); + uNodeDir + 1, uRootIndex, uLedgerIndex, bStable, true, j); } else { @@ -813,7 +821,7 @@ dirDelete (ApplyView& view, if (!bSoft) { assert (false); - WriteLog (lsWARNING, View) << "dirDelete: no such entry"; + JLOG (j.warning) << "dirDelete: no such entry"; return tefBAD_LEDGER; } @@ -821,7 +829,7 @@ dirDelete (ApplyView& view, { // Go the extra mile. Even if entry not in node, try the next node. return dirDelete (view, bKeepRoot, uNodeDir + 1, - uRootIndex, uLedgerIndex, bStable, true); + uRootIndex, uLedgerIndex, bStable, true, j); } return tefBAD_LEDGER; @@ -903,13 +911,13 @@ dirDelete (ApplyView& view, assert (slePrevious); if (!slePrevious) { - WriteLog (lsWARNING, View) << "dirDelete: previous node is missing"; + JLOG (j.warning) << "dirDelete: previous node is missing"; return tefBAD_LEDGER; } assert (sleNext); if (!sleNext) { - WriteLog (lsWARNING, View) << "dirDelete: next node is missing"; + JLOG (j.warning) << "dirDelete: next node is missing"; return tefBAD_LEDGER; } @@ -968,9 +976,10 @@ trustCreate (ApplyView& view, STAmount const& saLimit, // --> limit for account being set. // Issuer should be the account being set. std::uint32_t uQualityIn, - std::uint32_t uQualityOut) + std::uint32_t uQualityOut, + beast::Journal j) { - WriteLog (lsTRACE, View) + JLOG (j.trace) << "trustCreate: " << to_string (uSrcAccountID) << ", " << to_string (uDstAccountID) << ", " << saBalance.getFullText (); @@ -991,7 +1000,8 @@ trustCreate (ApplyView& view, [uLowAccountID](std::shared_ptr const& sle, bool) { sle->setAccountID (sfOwner, uLowAccountID); - }); + }, + j); if (tesSUCCESS == terResult) { @@ -1002,7 +1012,8 @@ trustCreate (ApplyView& view, [uHighAccountID](std::shared_ptr const& sle, bool) { sle->setAccountID (sfOwner, uHighAccountID); - }); + }, + j); } if (tesSUCCESS == terResult) @@ -1057,7 +1068,7 @@ trustCreate (ApplyView& view, } sleRippleState->setFieldU32 (sfFlags, uFlags); - adjustOwnerCount(view, sleAccount, 1); + adjustOwnerCount(view, sleAccount, 1, j); // ONLY: Create ripple balance. sleRippleState->setFieldAmount (sfBalance, bSetHigh ? -saBalance : saBalance); @@ -1073,7 +1084,8 @@ TER trustDelete (ApplyView& view, std::shared_ptr const& sleRippleState, AccountID const& uLowAccountID, - AccountID const& uHighAccountID) + AccountID const& uHighAccountID, + beast::Journal j) { // Detect legacy dirs. bool bLowNode = sleRippleState->isFieldPresent (sfLowNode); @@ -1082,7 +1094,7 @@ trustDelete (ApplyView& view, std::uint64_t uHighNode = sleRippleState->getFieldU64 (sfHighNode); TER terResult; - WriteLog (lsTRACE, View) + JLOG (j.trace) << "trustDelete: Deleting ripple line: low"; terResult = dirDelete(view, false, @@ -1090,11 +1102,12 @@ trustDelete (ApplyView& view, getOwnerDirIndex (uLowAccountID), sleRippleState->getIndex (), false, - !bLowNode); + !bLowNode, + j); if (tesSUCCESS == terResult) { - WriteLog (lsTRACE, View) + JLOG (j.trace) << "trustDelete: Deleting ripple line: high"; terResult = dirDelete (view, false, @@ -1102,10 +1115,11 @@ trustDelete (ApplyView& view, getOwnerDirIndex (uHighAccountID), sleRippleState->getIndex (), false, - !bHighNode); + !bHighNode, + j); } - WriteLog (lsTRACE, View) << "trustDelete: Deleting ripple line: state"; + JLOG (j.trace) << "trustDelete: Deleting ripple line: state"; view.erase(sleRippleState); return terResult; @@ -1113,7 +1127,8 @@ trustDelete (ApplyView& view, TER offerDelete (ApplyView& view, - std::shared_ptr const& sle) + std::shared_ptr const& sle, + beast::Journal j) { if (! sle) return tesSUCCESS; @@ -1127,13 +1142,13 @@ offerDelete (ApplyView& view, std::uint64_t uBookNode = sle->getFieldU64 (sfBookNode); TER terResult = dirDelete (view, false, uOwnerNode, - getOwnerDirIndex (owner), offerIndex, false, !bOwnerNode); + getOwnerDirIndex (owner), offerIndex, false, !bOwnerNode, j); TER terResult2 = dirDelete (view, false, uBookNode, - uDirectory, offerIndex, true, false); + uDirectory, offerIndex, true, false, j); if (tesSUCCESS == terResult) adjustOwnerCount(view, view.peek( - keylet::account(owner)), -1); + keylet::account(owner)), -1, j); view.erase(sle); @@ -1148,7 +1163,8 @@ offerDelete (ApplyView& view, TER rippleCredit (ApplyView& view, AccountID const& uSenderID, AccountID const& uReceiverID, - STAmount const& saAmount, bool bCheckIssuer) + STAmount const& saAmount, bool bCheckIssuer, + beast::Journal j) { auto issuer = saAmount.getIssuer (); auto currency = saAmount.getCurrency (); @@ -1178,7 +1194,7 @@ rippleCredit (ApplyView& view, saBalance.setIssuer (noAccount()); - WriteLog (lsDEBUG, View) << "rippleCredit: " + JLOG (j.debug) << "rippleCredit: " "create line: " << to_string (uSenderID) << " -> " << to_string (uReceiverID) << " : " << saAmount.getFullText (); @@ -1200,7 +1216,8 @@ rippleCredit (ApplyView& view, saBalance, saReceiverLimit, 0, - 0); + 0, + j); } else { @@ -1216,7 +1233,7 @@ rippleCredit (ApplyView& view, saBalance -= saAmount; - WriteLog (lsTRACE, View) << "rippleCredit: " << + JLOG (j.trace) << "rippleCredit: " << to_string (uSenderID) << " -> " << to_string (uReceiverID) << " : before=" << saBefore.getFullText () << @@ -1248,7 +1265,7 @@ rippleCredit (ApplyView& view, { // Clear the reserve of the sender, possibly delete the line! adjustOwnerCount(view, - view.peek(keylet::account(uSenderID)), -1); + view.peek(keylet::account(uSenderID)), -1, j); // Clear reserve flag. sleRippleState->setFieldU32 ( @@ -1273,7 +1290,7 @@ rippleCredit (ApplyView& view, terResult = trustDelete (view, sleRippleState, bSenderHigh ? uReceiverID : uSenderID, - !bSenderHigh ? uReceiverID : uSenderID); + !bSenderHigh ? uReceiverID : uSenderID, j); } else { @@ -1292,7 +1309,8 @@ rippleTransferFee (ReadView const& view, AccountID const& from, AccountID const& to, AccountID const& issuer, - STAmount const& saAmount) + STAmount const& saAmount, + beast::Journal j) { if (from != issuer && to != issuer) { @@ -1304,7 +1322,7 @@ rippleTransferFee (ReadView const& view, saAmount, amountFromRate (uTransitRate), saAmount.issue ()); STAmount saTransferFee = saTransferTotal - saAmount; - WriteLog (lsDEBUG, View) << "rippleTransferFee:" << + JLOG (j.debug) << "rippleTransferFee:" << " saTransferFee=" << saTransferFee.getFullText (); return saTransferFee; @@ -1321,7 +1339,7 @@ static TER rippleSend (ApplyView& view, AccountID const& uSenderID, AccountID const& uReceiverID, - STAmount const& saAmount, STAmount& saActual) + STAmount const& saAmount, STAmount& saActual, beast::Journal j) { auto const issuer = saAmount.getIssuer (); TER terResult; @@ -1333,7 +1351,7 @@ rippleSend (ApplyView& view, { // VFALCO Why do we need this bCheckIssuer? // Direct send: redeeming IOUs and/or sending own IOUs. - terResult = rippleCredit (view, uSenderID, uReceiverID, saAmount, false); + terResult = rippleCredit (view, uSenderID, uReceiverID, saAmount, false, j); saActual = saAmount; terResult = tesSUCCESS; } @@ -1342,23 +1360,23 @@ rippleSend (ApplyView& view, // Sending 3rd party IOUs: transit. STAmount saTransitFee = rippleTransferFee (view, - uSenderID, uReceiverID, issuer, saAmount); + uSenderID, uReceiverID, issuer, saAmount, j); saActual = !saTransitFee ? saAmount : saAmount + saTransitFee; saActual.setIssuer (issuer); // XXX Make sure this done in + above. - WriteLog (lsDEBUG, View) << "rippleSend> " << + JLOG (j.debug) << "rippleSend> " << to_string (uSenderID) << " - > " << to_string (uReceiverID) << " : deliver=" << saAmount.getFullText () << " fee=" << saTransitFee.getFullText () << " cost=" << saActual.getFullText (); - terResult = rippleCredit (view, issuer, uReceiverID, saAmount, true); + terResult = rippleCredit (view, issuer, uReceiverID, saAmount, true, j); if (tesSUCCESS == terResult) - terResult = rippleCredit (view, uSenderID, issuer, saActual, true); + terResult = rippleCredit (view, uSenderID, issuer, saActual, true, j); } return terResult; @@ -1367,7 +1385,7 @@ rippleSend (ApplyView& view, TER accountSend (ApplyView& view, AccountID const& uSenderID, AccountID const& uReceiverID, - STAmount const& saAmount) + STAmount const& saAmount, beast::Journal j) { assert (saAmount >= zero); @@ -1381,11 +1399,11 @@ accountSend (ApplyView& view, { STAmount saActual; - WriteLog (lsTRACE, View) << "accountSend: " << + JLOG (j.trace) << "accountSend: " << to_string (uSenderID) << " -> " << to_string (uReceiverID) << " : " << saAmount.getFullText (); - return rippleSend (view, uSenderID, uReceiverID, saAmount, saActual); + return rippleSend (view, uSenderID, uReceiverID, saAmount, saActual, j); } view.creditHook (uSenderID, @@ -1417,7 +1435,7 @@ accountSend (ApplyView& view, if (receiver) receiver_bal = receiver->getFieldAmount (sfBalance).getFullText (); - WriteLog (lsTRACE, View) << "accountSend> " << + JLOG (j.trace) << "accountSend> " << to_string (uSenderID) << " (" << sender_bal << ") -> " << to_string (uReceiverID) << " (" << receiver_bal << ") : " << saAmount.getFullText (); @@ -1461,7 +1479,7 @@ accountSend (ApplyView& view, if (receiver) receiver_bal = receiver->getFieldAmount (sfBalance).getFullText (); - WriteLog (lsTRACE, View) << "accountSend< " << + JLOG (j.trace) << "accountSend< " << to_string (uSenderID) << " (" << sender_bal << ") -> " << to_string (uReceiverID) << " (" << receiver_bal << ") : " << saAmount.getFullText (); @@ -1478,7 +1496,8 @@ updateTrustLine ( bool bSenderHigh, AccountID const& sender, STAmount const& before, - STAmount const& after) + STAmount const& after, + beast::Journal j) { std::uint32_t const flags (state->getFieldU32 (sfFlags)); @@ -1507,7 +1526,7 @@ updateTrustLine ( { // VFALCO Where is the line being deleted? // Clear the reserve of the sender, possibly delete the line! - adjustOwnerCount(view, sle, -1); + adjustOwnerCount(view, sle, -1, j); // Clear reserve flag. state->setFieldU32 (sfFlags, @@ -1525,7 +1544,7 @@ updateTrustLine ( TER issueIOU (ApplyView& view, AccountID const& account, - STAmount const& amount, Issue const& issue) + STAmount const& amount, Issue const& issue, beast::Journal j) { assert (!isXRP (account) && !isXRP (issue.account)); @@ -1535,7 +1554,7 @@ issueIOU (ApplyView& view, // Can't send to self! assert (issue.account != account); - WriteLog (lsTRACE, View) << "issueIOU: " << + JLOG (j.trace) << "issueIOU: " << to_string (account) << ": " << amount.getFullText (); @@ -1559,7 +1578,7 @@ issueIOU (ApplyView& view, bool noRipple = (receiverAccount->getFlags() & lsfDefaultRipple) == 0; return trustCreate (view, bSenderHigh, issue.account, account, index, - receiverAccount, false, noRipple, false, final_balance, limit, 0, 0); + receiverAccount, false, noRipple, false, final_balance, limit, 0, 0, j); } STAmount final_balance = state->getFieldAmount (sfBalance); @@ -1572,7 +1591,7 @@ issueIOU (ApplyView& view, final_balance -= amount; auto const must_delete = updateTrustLine(view, state, bSenderHigh, issue.account, - start_balance, final_balance); + start_balance, final_balance, j); if (bSenderHigh) final_balance.negate (); @@ -1587,7 +1606,7 @@ issueIOU (ApplyView& view, if (must_delete) return trustDelete (view, state, bSenderHigh ? account : issue.account, - bSenderHigh ? issue.account : account); + bSenderHigh ? issue.account : account, j); view.update (state); @@ -1598,7 +1617,8 @@ TER redeemIOU (ApplyView& view, AccountID const& account, STAmount const& amount, - Issue const& issue) + Issue const& issue, + beast::Journal j) { assert (!isXRP (account) && !isXRP (issue.account)); @@ -1608,7 +1628,7 @@ redeemIOU (ApplyView& view, // Can't send to self! assert (issue.account != account); - WriteLog (lsTRACE, View) << "redeemIOU: " << + JLOG (j.trace) << "redeemIOU: " << to_string (account) << ": " << amount.getFullText (); @@ -1622,7 +1642,7 @@ redeemIOU (ApplyView& view, // In order to hold an IOU, a trust line *MUST* exist to track the // balance. If it doesn't, then something is very wrong. Don't try // to continue. - WriteLog (lsFATAL, View) << "redeemIOU: " << + JLOG (j.fatal) << "redeemIOU: " << to_string (account) << " attempts to redeem " << amount.getFullText () << " but no trust line exists!"; @@ -1639,7 +1659,7 @@ redeemIOU (ApplyView& view, final_balance -= amount; auto const must_delete = updateTrustLine (view, state, bSenderHigh, account, - start_balance, final_balance); + start_balance, final_balance, j); if (bSenderHigh) final_balance.negate (); @@ -1656,7 +1676,7 @@ redeemIOU (ApplyView& view, { return trustDelete (view, state, bSenderHigh ? issue.account : account, - bSenderHigh ? account : issue.account); + bSenderHigh ? account : issue.account, j); } view.update (state); @@ -1667,7 +1687,8 @@ TER transferXRP (ApplyView& view, AccountID const& from, AccountID const& to, - STAmount const& amount) + STAmount const& amount, + beast::Journal j) { assert (from != beast::zero); assert (to != beast::zero); @@ -1677,7 +1698,7 @@ transferXRP (ApplyView& view, SLE::pointer sender = view.peek (keylet::account(from)); SLE::pointer receiver = view.peek (keylet::account(to)); - WriteLog (lsTRACE, View) << "transferXRP: " << + JLOG (j.trace) << "transferXRP: " << to_string (from) << " -> " << to_string (to) << ") : " << amount.getFullText (); diff --git a/src/ripple/ledger/tests/PaymentSandbox_test.cpp b/src/ripple/ledger/tests/PaymentSandbox_test.cpp index 957a0e6200..40bf37eea5 100644 --- a/src/ripple/ledger/tests/PaymentSandbox_test.cpp +++ b/src/ripple/ledger/tests/PaymentSandbox_test.cpp @@ -104,6 +104,8 @@ class PaymentSandbox_test : public beast::unit_test::suite env.fund (XRP (10000), alice, gw1, gw2); + auto j = env.app().journal ("View"); + auto const USD_gw1 = gw1["USD"]; auto const USD_gw2 = gw2["USD"]; @@ -121,16 +123,16 @@ class PaymentSandbox_test : public beast::unit_test::suite auto const iss = USD_gw1.issue (); auto const startingAmount = accountHolds ( - av, alice, iss.currency, iss.account, fhIGNORE_FREEZE); + av, alice, iss.currency, iss.account, fhIGNORE_FREEZE, j); - accountSend (av, gw1, alice, toCredit); + accountSend (av, gw1, alice, toCredit, j); expect (accountHolds (av, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount + toCredit); - accountSend (av, alice, gw1, toDebit); + accountSend (av, alice, gw1, toDebit, j); expect (accountHolds (av, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount + toCredit - toDebit); } @@ -140,16 +142,16 @@ class PaymentSandbox_test : public beast::unit_test::suite auto const iss = USD_gw1.issue (); auto const startingAmount = accountHolds ( - av, alice, iss.currency, iss.account, fhIGNORE_FREEZE); + av, alice, iss.currency, iss.account, fhIGNORE_FREEZE, j); - rippleCredit (av, gw1, alice, toCredit, true); + rippleCredit (av, gw1, alice, toCredit, true, j); expect (accountHolds (av, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount + toCredit); - rippleCredit (av, alice, gw1, toDebit, true); + rippleCredit (av, alice, gw1, toDebit, true, j); expect (accountHolds (av, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount + toCredit - toDebit); } @@ -160,16 +162,16 @@ class PaymentSandbox_test : public beast::unit_test::suite auto const iss = USD_gw1.issue (); auto const startingAmount = accountHolds ( - pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE); + pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE, j); - accountSend (pv, gw1, alice, toCredit); + accountSend (pv, gw1, alice, toCredit, j); expect (accountHolds (pv, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount); - accountSend (pv, alice, gw1, toDebit); + accountSend (pv, alice, gw1, toDebit, j); expect (accountHolds (pv, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount - toDebit); } @@ -180,11 +182,11 @@ class PaymentSandbox_test : public beast::unit_test::suite auto const iss = USD_gw1.issue (); auto const startingAmount = accountHolds ( - pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE); + pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE, j); - rippleCredit (pv, gw1, alice, toCredit, true); + rippleCredit (pv, gw1, alice, toCredit, true, j); expect (accountHolds (pv, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount); } @@ -195,11 +197,11 @@ class PaymentSandbox_test : public beast::unit_test::suite auto const iss = USD_gw1.issue (); auto const startingAmount = accountHolds ( - pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE); + pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE, j); - redeemIOU (pv, alice, toDebit, iss); + redeemIOU (pv, alice, toDebit, iss, j); expect (accountHolds (pv, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount - toDebit); } @@ -210,11 +212,11 @@ class PaymentSandbox_test : public beast::unit_test::suite auto const iss = USD_gw1.issue (); auto const startingAmount = accountHolds ( - pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE); + pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE, j); - issueIOU (pv, alice, toCredit, iss); + issueIOU (pv, alice, toCredit, iss, j); expect (accountHolds (pv, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount); } @@ -225,27 +227,27 @@ class PaymentSandbox_test : public beast::unit_test::suite auto const iss = USD_gw1.issue (); auto const startingAmount = accountHolds ( - pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE); + pv, alice, iss.currency, iss.account, fhIGNORE_FREEZE, j); - accountSend (pv, gw1, alice, toCredit); + accountSend (pv, gw1, alice, toCredit, j); expect (accountHolds (pv, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount); { PaymentSandbox pv2(&pv); expect (accountHolds (pv2, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount); - accountSend (pv2, gw1, alice, toCredit); + accountSend (pv2, gw1, alice, toCredit, j); expect (accountHolds (pv2, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount); } - accountSend (pv, alice, gw1, toDebit); + accountSend (pv, alice, gw1, toDebit, j); expect (accountHolds (pv, alice, iss.currency, iss.account, - fhIGNORE_FREEZE) == + fhIGNORE_FREEZE, j) == startingAmount - toDebit); } } diff --git a/src/ripple/net/HTTPClient.h b/src/ripple/net/HTTPClient.h index f63baef243..579cfb22a5 100644 --- a/src/ripple/net/HTTPClient.h +++ b/src/ripple/net/HTTPClient.h @@ -47,7 +47,8 @@ public: std::string const& strPath, std::size_t responseMax, boost::posix_time::time_duration timeout, - std::function complete); + std::function complete, + Logs& l); static void get ( bool bSSL, @@ -57,7 +58,8 @@ public: std::string const& strPath, std::size_t responseMax, boost::posix_time::time_duration timeout, - std::function complete); + std::function complete, + Logs& l); static void request ( bool bSSL, @@ -67,7 +69,8 @@ public: std::function build, std::size_t responseMax, boost::posix_time::time_duration timeout, - std::function complete); + std::function complete, + Logs& l); }; } // ripple diff --git a/src/ripple/net/RPCCall.h b/src/ripple/net/RPCCall.h index f7e3a1e68c..a131ec4c0e 100644 --- a/src/ripple/net/RPCCall.h +++ b/src/ripple/net/RPCCall.h @@ -40,7 +40,8 @@ namespace RPCCall { int fromCommandLine ( Config const& config, - const std::vector& vCmd); + const std::vector& vCmd, + Logs& logs); void fromNetwork ( boost::asio::io_service& io_service, @@ -48,6 +49,7 @@ void fromNetwork ( std::string const& strUsername, std::string const& strPassword, std::string const& strPath, std::string const& strMethod, Json::Value const& jvParams, const bool bSSL, bool quiet, + Logs& logs, std::function callbackFuncP = std::function ()); } diff --git a/src/ripple/net/RPCSub.h b/src/ripple/net/RPCSub.h index 3418ef7183..71829aecc5 100644 --- a/src/ripple/net/RPCSub.h +++ b/src/ripple/net/RPCSub.h @@ -42,7 +42,8 @@ protected: std::shared_ptr make_RPCSub ( InfoSub::Source& source, boost::asio::io_service& io_service, JobQueue& jobQueue, std::string const& strUrl, - std::string const& strUsername, std::string const& strPassword); + std::string const& strUsername, std::string const& strPassword, + Logs& logs); } // ripple diff --git a/src/ripple/net/impl/HTTPClient.cpp b/src/ripple/net/impl/HTTPClient.cpp index 120da4b8e1..536fc43aa7 100644 --- a/src/ripple/net/impl/HTTPClient.cpp +++ b/src/ripple/net/impl/HTTPClient.cpp @@ -98,14 +98,16 @@ class HTTPClientImp { public: HTTPClientImp (boost::asio::io_service& io_service, - const unsigned short port, - std::size_t responseMax) - : mSocket (io_service, httpClientSSLContext->context()) + const unsigned short port, + std::size_t responseMax, + Logs& l) + : mSocket (io_service, httpClientSSLContext->context (), l.journal ("AutoSocket")) , mResolver (io_service) , mHeader (maxClientHeaderBytes) , mPort (port) , mResponseMax (responseMax) , mDeadline (io_service) + , j_ (l.journal ("HTTPClient")) { if (!httpClientSSLContext->sslVerify()) mSocket.SSLSocket ().set_verify_mode (boost::asio::ssl::verify_none); @@ -171,7 +173,7 @@ public: void httpsNext () { - WriteLog (lsTRACE, HTTPClient) << "Fetch: " << mDeqSites[0]; + JLOG (j_.trace) << "Fetch: " << mDeqSites[0]; auto query = std::make_shared( mDeqSites[0], @@ -181,7 +183,7 @@ public: mDeadline.expires_from_now (mTimeout, mShutdown); - WriteLog (lsTRACE, HTTPClient) << "expires_from_now: " << mShutdown.message (); + JLOG (j_.trace) << "expires_from_now: " << mShutdown.message (); if (!mShutdown) { @@ -194,7 +196,7 @@ public: if (!mShutdown) { - WriteLog (lsTRACE, HTTPClient) << "Resolving: " << mDeqSites[0]; + JLOG (j_.trace) << "Resolving: " << mDeqSites[0]; mResolver.async_resolve (*mQuery, std::bind ( @@ -213,20 +215,20 @@ public: if (ecResult == boost::asio::error::operation_aborted) { // Timer canceled because deadline no longer needed. - WriteLog (lsTRACE, HTTPClient) << "Deadline cancelled."; + JLOG (j_.trace) << "Deadline cancelled."; // Aborter is done. } else if (ecResult) { - WriteLog (lsTRACE, HTTPClient) << "Deadline error: " << mDeqSites[0] << ": " << ecResult.message (); + JLOG (j_.trace) << "Deadline error: " << mDeqSites[0] << ": " << ecResult.message (); // Can't do anything sound. abort (); } else { - WriteLog (lsTRACE, HTTPClient) << "Deadline arrived."; + JLOG (j_.trace) << "Deadline arrived."; // Mark us as shutting down. // XXX Use our own error code. @@ -250,7 +252,7 @@ public: { if (ecResult) { - WriteLog (lsTRACE, HTTPClient) << "Shutdown error: " << mDeqSites[0] << ": " << ecResult.message (); + JLOG (j_.trace) << "Shutdown error: " << mDeqSites[0] << ": " << ecResult.message (); } } @@ -264,13 +266,13 @@ public: if (mShutdown) { - WriteLog (lsTRACE, HTTPClient) << "Resolve error: " << mDeqSites[0] << ": " << mShutdown.message (); + JLOG (j_.trace) << "Resolve error: " << mDeqSites[0] << ": " << mShutdown.message (); invokeComplete (mShutdown); } else { - WriteLog (lsTRACE, HTTPClient) << "Resolve complete."; + JLOG (j_.trace) << "Resolve complete."; boost::asio::async_connect ( mSocket.lowest_layer (), @@ -289,12 +291,12 @@ public: if (mShutdown) { - WriteLog (lsTRACE, HTTPClient) << "Connect error: " << mShutdown.message (); + JLOG (j_.trace) << "Connect error: " << mShutdown.message (); } if (!mShutdown) { - WriteLog (lsTRACE, HTTPClient) << "Connected."; + JLOG (j_.trace) << "Connected."; if (httpClientSSLContext->sslVerify ()) { @@ -302,7 +304,7 @@ public: if (mShutdown) { - WriteLog (lsTRACE, HTTPClient) << "set_verify_callback: " << mDeqSites[0] << ": " << mShutdown.message (); + JLOG (j_.trace) << "set_verify_callback: " << mDeqSites[0] << ": " << mShutdown.message (); } } } @@ -333,13 +335,13 @@ public: if (mShutdown) { - WriteLog (lsTRACE, HTTPClient) << "Handshake error:" << mShutdown.message (); + JLOG (j_.trace) << "Handshake error:" << mShutdown.message (); invokeComplete (mShutdown); } else { - WriteLog (lsTRACE, HTTPClient) << "Session started."; + JLOG (j_.trace) << "Session started."; mBuild (mRequest, mDeqSites[0]); @@ -359,13 +361,13 @@ public: if (mShutdown) { - WriteLog (lsTRACE, HTTPClient) << "Write error: " << mShutdown.message (); + JLOG (j_.trace) << "Write error: " << mShutdown.message (); invokeComplete (mShutdown); } else { - WriteLog (lsTRACE, HTTPClient) << "Wrote."; + JLOG (j_.trace) << "Wrote."; mSocket.async_read_until ( mHeader, @@ -380,7 +382,7 @@ public: void handleHeader (const boost::system::error_code& ecResult, std::size_t bytes_transferred) { std::string strHeader ((std::istreambuf_iterator (&mHeader)), std::istreambuf_iterator ()); - WriteLog (lsTRACE, HTTPClient) << "Header: \"" << strHeader << "\""; + JLOG (j_.trace) << "Header: \"" << strHeader << "\""; static boost::regex reStatus ("\\`HTTP/1\\S+ (\\d{3}) .*\\'"); // HTTP/1.1 200 OK static boost::regex reSize ("\\`.*\\r\\nContent-Length:\\s+([0-9]+).*\\'"); @@ -393,7 +395,7 @@ public: if (!bMatch) { // XXX Use our own error code. - WriteLog (lsTRACE, HTTPClient) << "No status code"; + JLOG (j_.trace) << "No status code"; invokeComplete (boost::system::error_code (boost::system::errc::bad_address, boost::system::system_category ())); return; } @@ -440,7 +442,7 @@ public: if (mShutdown && mShutdown != boost::asio::error::eof) { - WriteLog (lsTRACE, HTTPClient) << "Read error: " << mShutdown.message (); + JLOG (j_.trace) << "Read error: " << mShutdown.message (); invokeComplete (mShutdown); } @@ -448,7 +450,7 @@ public: { if (mShutdown) { - WriteLog (lsTRACE, HTTPClient) << "Complete."; + JLOG (j_.trace) << "Complete."; } else { @@ -468,10 +470,10 @@ public: if (ecCancel) { - WriteLog (lsTRACE, HTTPClient) << "invokeComplete: Deadline cancel error: " << ecCancel.message (); + JLOG (j_.trace) << "invokeComplete: Deadline cancel error: " << ecCancel.message (); } - WriteLog (lsDEBUG, HTTPClient) << "invokeComplete: Deadline popping: " << mDeqSites.size (); + JLOG (j_.debug) << "invokeComplete: Deadline popping: " << mDeqSites.size (); if (!mDeqSites.empty ()) { @@ -518,6 +520,7 @@ private: std::deque mDeqSites; boost::posix_time::time_duration mTimeout; + beast::Journal j_; }; //------------------------------------------------------------------------------ @@ -531,10 +534,11 @@ void HTTPClient::get ( std::size_t responseMax, boost::posix_time::time_duration timeout, std::function complete) + std::string const& strData)> complete, + Logs& l) { auto client = std::make_shared ( - io_service, port, responseMax); + io_service, port, responseMax, l); client->get (bSSL, deqSites, strPath, timeout, complete); } @@ -547,12 +551,13 @@ void HTTPClient::get ( std::size_t responseMax, boost::posix_time::time_duration timeout, std::function complete) + std::string const& strData)> complete, + Logs& l) { std::deque deqSites (1, strSite); auto client = std::make_shared ( - io_service, port, responseMax); + io_service, port, responseMax, l); client->get (bSSL, deqSites, strPath, timeout, complete); } @@ -565,12 +570,13 @@ void HTTPClient::request ( std::size_t responseMax, boost::posix_time::time_duration timeout, std::function complete) + std::string const& strData)> complete, + Logs& l) { std::deque deqSites (1, strSite); auto client = std::make_shared ( - io_service, port, responseMax); + io_service, port, responseMax, l); client->request (bSSL, deqSites, setRequest, timeout, complete); } diff --git a/src/ripple/net/impl/HTTPRequest.cpp b/src/ripple/net/impl/HTTPRequest.cpp index 7a0a54cab3..f763917f54 100644 --- a/src/ripple/net/impl/HTTPRequest.cpp +++ b/src/ripple/net/impl/HTTPRequest.cpp @@ -63,8 +63,6 @@ HTTPRequest::Action HTTPRequest::consume (boost::asio::streambuf& buf) std::getline (is, line); boost::trim (line); - // WriteLog (lsTRACE, HTTPRequest) << "HTTPRequest line: " << line; - if (eState == await_request) { // VERB URL PROTO diff --git a/src/ripple/net/impl/RPCCall.cpp b/src/ripple/net/impl/RPCCall.cpp index 451bbebde8..03ff388848 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -81,6 +81,8 @@ std::string createHTTPPost ( class RPCParser { private: + beast::Journal j_; + // TODO New routine for parsing ledger parameters, other routines should standardize on this. static bool jvParseLedger (Json::Value& jvRequest, std::string const& strLedger) { @@ -457,8 +459,8 @@ private: Json::Reader reader; Json::Value jvRequest; - WriteLog (lsTRACE, RPCParser) << "RPC method: " << jvParams[0u]; - WriteLog (lsTRACE, RPCParser) << "RPC json: " << jvParams[1u]; + JLOG (j_.trace) << "RPC method: " << jvParams[0u]; + JLOG (j_.trace) << "RPC json: " << jvParams[1u]; if (reader.parse (jvParams[1u].asString (), jvRequest)) { @@ -610,7 +612,7 @@ private: Json::Value jvRequest; bool bLedger = 2 == jvParams.size (); - WriteLog (lsTRACE, RPCParser) << "RPC json: " << jvParams[0u]; + JLOG (j_.trace) << "RPC json: " << jvParams[0u]; if (reader.parse (jvParams[0u].asString (), jvRequest)) { @@ -838,6 +840,10 @@ private: public: //-------------------------------------------------------------------------- + explicit + RPCParser (beast::Journal j) + :j_ (j){} + static std::string EncodeBase64 (std::string const& s) { // FIXME: This performs terribly @@ -870,8 +876,8 @@ public: { if (ShouldLog (lsTRACE, RPCParser)) { - WriteLog (lsTRACE, RPCParser) << "RPC method:" << strMethod; - WriteLog (lsTRACE, RPCParser) << "RPC params:" << jvParams; + JLOG (j_.trace) << "RPC method:" << strMethod; + JLOG (j_.trace) << "RPC params:" << jvParams; } struct Command @@ -962,7 +968,7 @@ public: if ((command.minParams >= 0 && count < command.minParams) || (command.maxParams >= 0 && count > command.maxParams)) { - WriteLog (lsDEBUG, RPCParser) << + JLOG (j_.debug) << "Wrong number of parameters for " << command.name << " minimum=" << command.minParams << " maximum=" << command.maxParams << @@ -1015,7 +1021,7 @@ struct RPCCallImp static bool onResponse ( std::function callbackFuncP, const boost::system::error_code& ecResult, int iStatus, - std::string const& strData) + std::string const& strData, beast::Journal j) { if (callbackFuncP) { @@ -1030,7 +1036,7 @@ struct RPCCallImp throw std::runtime_error ("no response from server"); // Parse reply - WriteLog (lsDEBUG, RPCParser) << "RPC reply: " << strData << std::endl; + JLOG (j.debug) << "RPC reply: " << strData << std::endl; Json::Reader reader; Json::Value jvReply; @@ -1054,9 +1060,9 @@ struct RPCCallImp // Build the request. static void onRequest (std::string const& strMethod, Json::Value const& jvParams, const std::map& mHeaders, std::string const& strPath, - boost::asio::streambuf& sb, std::string const& strHost) + boost::asio::streambuf& sb, std::string const& strHost, beast::Journal j) { - WriteLog (lsDEBUG, RPCParser) << "requestRPC: strPath='" << strPath << "'"; + JLOG (j.debug) << "requestRPC: strPath='" << strPath << "'"; std::ostream osRequest (&sb); osRequest << @@ -1073,7 +1079,8 @@ namespace RPCCall { int fromCommandLine ( Config const& config, - const std::vector& vCmd) + const std::vector& vCmd, + Logs& logs) { if (vCmd.empty ()) return 1; // 1 = print usage. @@ -1082,9 +1089,10 @@ int fromCommandLine ( int nRet = 0; Json::Value jvRequest (Json::objectValue); + auto rpcJ = logs.journal ("RPCParser"); try { - RPCParser rpParser; + RPCParser rpParser (rpcJ); Json::Value jvRpcParams (Json::arrayValue); for (int i = 1; i != vCmd.size (); i++) @@ -1097,7 +1105,7 @@ int fromCommandLine ( jvRequest = rpParser.parseCommand (vCmd[0], jvRpcParams, true); - WriteLog (lsTRACE, RPCParser) << "RPC Request: " << jvRequest << std::endl; + JLOG (rpcJ.trace) << "RPC Request: " << jvRequest << std::endl; if (jvRequest.isMember (jss::error)) { @@ -1147,6 +1155,7 @@ int fromCommandLine ( jvParams, // Parsed, execute. setup.client.secure != 0, // Use SSL config.QUIET, + logs, std::bind (RPCCallImp::callRPCHandler, &jvOutput, std::placeholders::_1)); isService.run(); // This blocks until there is no more outstanding async calls. @@ -1215,6 +1224,7 @@ void fromNetwork ( std::string const& strUsername, std::string const& strPassword, std::string const& strPath, std::string const& strMethod, Json::Value const& jvParams, const bool bSSL, const bool quiet, + Logs& logs, std::function callbackFuncP) { // Connect to localhost @@ -1236,6 +1246,8 @@ void fromNetwork ( const int RPC_REPLY_MAX_BYTES (256*1024*1024); const int RPC_NOTIFY_SECONDS (600); + auto j = logs.journal ("HTTPClient"); + HTTPClient::request ( bSSL, io_service, @@ -1246,12 +1258,13 @@ void fromNetwork ( strMethod, jvParams, mapRequestHeaders, - strPath, std::placeholders::_1, std::placeholders::_2), + strPath, std::placeholders::_1, std::placeholders::_2, j), RPC_REPLY_MAX_BYTES, boost::posix_time::seconds (RPC_NOTIFY_SECONDS), std::bind (&RPCCallImp::onResponse, callbackFuncP, std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)); + std::placeholders::_3, j), + logs); } } diff --git a/src/ripple/net/impl/RPCSub.cpp b/src/ripple/net/impl/RPCSub.cpp index 105e4c481b..a6f396c6fe 100644 --- a/src/ripple/net/impl/RPCSub.cpp +++ b/src/ripple/net/impl/RPCSub.cpp @@ -34,7 +34,7 @@ class RPCSubImp public: RPCSubImp (InfoSub::Source& source, boost::asio::io_service& io_service, JobQueue& jobQueue, std::string const& strUrl, std::string const& strUsername, - std::string const& strPassword) + std::string const& strPassword, Logs& logs) : RPCSub (source) , m_io_service (io_service) , m_jobQueue (jobQueue) @@ -43,6 +43,8 @@ public: , mUsername (strUsername) , mPassword (strPassword) , mSending (false) + , j_ (logs.journal ("RPCSub")) + , logs_ (logs) { std::string strScheme; @@ -64,7 +66,7 @@ public: if (mPort < 0) mPort = mSSL ? 443 : 80; - WriteLog (lsINFO, RPCSub) << + JLOG (j_.info) << "RPCCall::fromNetwork sub: ip=" << mIp << " port=" << mPort << " ssl= "<< (mSSL ? "yes" : "no") << @@ -82,11 +84,12 @@ public: if (mDeque.size () >= eventQueueMax) { // Drop the previous event. - WriteLog (lsWARNING, RPCSub) << "RPCCall::fromNetwork drop"; + JLOG (j_.warning) << "RPCCall::fromNetwork drop"; mDeque.pop_back (); } - WriteLog (broadcast ? lsDEBUG : lsINFO, RPCSub) << + auto& jm = broadcast ? j_.debug : j_.info; + JLOG (jm) << "RPCCall::fromNetwork push: " << jvObj; mDeque.push_back (std::make_pair (mSeq++, jvObj)); @@ -96,7 +99,7 @@ public: // Start a sending thread. mSending = true; - WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork start"; + JLOG (j_.info) << "RPCCall::fromNetwork start"; m_jobQueue.addJob ( jtCLIENT, "RPCSub::sendThread", [this] (Job&) { @@ -156,7 +159,7 @@ private: // XXX Might not need this in a try. try { - WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork: " << mIp; + JLOG (j_.info) << "RPCCall::fromNetwork: " << mIp; RPCCall::fromNetwork ( m_io_service, @@ -165,11 +168,12 @@ private: mPath, "event", jvEvent, mSSL, - true); + true, + logs_); } catch (const std::exception& e) { - WriteLog (lsINFO, RPCSub) << "RPCCall::fromNetwork exception: " << e.what (); + JLOG (j_.info) << "RPCCall::fromNetwork exception: " << e.what (); } } } @@ -198,6 +202,9 @@ private: bool mSending; // Sending threead is active. std::deque > mDeque; + + beast::Journal j_; + Logs& logs_; }; //------------------------------------------------------------------------------ @@ -210,11 +217,12 @@ RPCSub::RPCSub (InfoSub::Source& source) std::shared_ptr make_RPCSub ( InfoSub::Source& source, boost::asio::io_service& io_service, JobQueue& jobQueue, std::string const& strUrl, - std::string const& strUsername, std::string const& strPassword) + std::string const& strUsername, std::string const& strPassword, + Logs& logs) { return std::make_shared (std::ref (source), std::ref (io_service), std::ref (jobQueue), - strUrl, strUsername, strPassword); + strUrl, strUsername, strPassword, logs); } } // ripple diff --git a/src/ripple/overlay/PeerSet.h b/src/ripple/overlay/PeerSet.h index 60d060c778..67700f7736 100644 --- a/src/ripple/overlay/PeerSet.h +++ b/src/ripple/overlay/PeerSet.h @@ -111,7 +111,9 @@ public: } private: - static void timerEntry (std::weak_ptr, const boost::system::error_code& result); + static void timerEntry ( + std::weak_ptr, const boost::system::error_code& result, + beast::Journal j); static void timerJobEntry (std::shared_ptr); protected: diff --git a/src/ripple/overlay/impl/Manifest.cpp b/src/ripple/overlay/impl/Manifest.cpp index 642558df11..61f234866e 100644 --- a/src/ripple/overlay/impl/Manifest.cpp +++ b/src/ripple/overlay/impl/Manifest.cpp @@ -119,7 +119,7 @@ bool Manifest::revoked () const void ManifestCache::configValidatorKey( - std::string const& line, beast::Journal const& journal) + std::string const& line, beast::Journal journal) { auto const words = beast::rfc2616::split(line.begin(), line.end(), ' '); @@ -157,7 +157,7 @@ ManifestCache::configValidatorKey( void ManifestCache::configManifest ( - Manifest m, UniqueNodeList& unl, beast::Journal const& journal) + Manifest m, UniqueNodeList& unl, beast::Journal journal) { if (!m.verify()) { @@ -190,7 +190,7 @@ ManifestCache::addTrustedKey (PublicKey const& pk, std::string comment) ManifestDisposition ManifestCache::canApply (PublicKey const& pk, std::uint32_t seq, - beast::Journal const& journal) const + beast::Journal journal) const { auto const iter = map_.find(pk); @@ -227,7 +227,7 @@ ManifestCache::canApply (PublicKey const& pk, std::uint32_t seq, ManifestDisposition ManifestCache::applyManifest ( - Manifest m, UniqueNodeList& unl, beast::Journal const& journal) + Manifest m, UniqueNodeList& unl, beast::Journal journal) { { std::lock_guard lock (mutex_); @@ -334,7 +334,7 @@ ManifestCache::applyManifest ( } void ManifestCache::load ( - DatabaseCon& dbCon, UniqueNodeList& unl, beast::Journal const& journal) + DatabaseCon& dbCon, UniqueNodeList& unl, beast::Journal journal) { static const char* const sql = "SELECT RawData FROM ValidatorManifests;"; diff --git a/src/ripple/overlay/impl/Manifest.h b/src/ripple/overlay/impl/Manifest.h index 0d342c3b4d..9412a0a607 100644 --- a/src/ripple/overlay/impl/Manifest.h +++ b/src/ripple/overlay/impl/Manifest.h @@ -185,7 +185,7 @@ private: ManifestDisposition canApply (PublicKey const& pk, std::uint32_t seq, - beast::Journal const& journal) const; + beast::Journal journal) const; public: ManifestCache() = default; @@ -193,17 +193,17 @@ public: ManifestCache& operator= (ManifestCache const&) = delete; ~ManifestCache() = default; - void configValidatorKey(std::string const& line, beast::Journal const& journal); - void configManifest (Manifest m, UniqueNodeList& unl, beast::Journal const& journal); + void configValidatorKey(std::string const& line, beast::Journal journal); + void configManifest (Manifest m, UniqueNodeList& unl, beast::Journal journal); void addTrustedKey (PublicKey const& pk, std::string comment); ManifestDisposition applyManifest ( - Manifest m, UniqueNodeList& unl, beast::Journal const& journal); + Manifest m, UniqueNodeList& unl, beast::Journal journal); void load ( - DatabaseCon& dbCon, UniqueNodeList& unl, beast::Journal const& journal); + DatabaseCon& dbCon, UniqueNodeList& unl, beast::Journal journal); void save (DatabaseCon& dbCon) const; // A "for_each" for populated manifests only diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index cafa80846f..ed43a527c2 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_ (app_.logs().journal("Overlay")) + , journal_ (app_.journal("Overlay")) , serverHandler_(serverHandler) , m_resourceManager (resourceManager) , m_peerFinder (PeerFinder::make_Manager (*this, io_service, - stopwatch(), app_.logs().journal("PeerFinder"), config)) + stopwatch(), app_.journal("PeerFinder"), config)) , m_resolver (resolver) , next_id_(1) , timer_count_(0) @@ -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, - app_.logs().journal("Peer"), *this); + app_.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 283ef83828..2e2d0b92a7 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_(app_.logs().journal("Peer"), makePrefix(id)) - , p_sink_(app_.logs().journal("Protocol"), makePrefix(id)) + , sink_(app_.journal("Peer"), makePrefix(id)) + , p_sink_(app_.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 d2c8b87a3e..d930216dd8 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_ (app_.logs().journal("Peer"), makePrefix(id)) - , p_sink_ (app_.logs().journal("Protocol"), makePrefix(id)) + , sink_ (app_.journal("Peer"), makePrefix(id)) + , p_sink_ (app_.journal("Protocol"), makePrefix(id)) , journal_ (sink_) , p_journal_ (p_sink_) , ssl_bundle_(std::move(ssl_bundle)) diff --git a/src/ripple/overlay/impl/PeerSet.cpp b/src/ripple/overlay/impl/PeerSet.cpp index fbea72f673..5cedee1587 100644 --- a/src/ripple/overlay/impl/PeerSet.cpp +++ b/src/ripple/overlay/impl/PeerSet.cpp @@ -72,7 +72,8 @@ bool PeerSet::insert (Peer::ptr const& ptr) void PeerSet::setTimer () { mTimer.expires_from_now (boost::posix_time::milliseconds (mTimerInterval)); - mTimer.async_wait (std::bind (&PeerSet::timerEntry, pmDowncast (), beast::asio::placeholders::error)); + mTimer.async_wait (std::bind (&PeerSet::timerEntry, pmDowncast (), + beast::asio::placeholders::error, m_journal)); } void PeerSet::invokeOnTimer () @@ -85,7 +86,7 @@ void PeerSet::invokeOnTimer () if (!isProgress()) { ++mTimeouts; - WriteLog (lsDEBUG, InboundLedger) << "Timeout(" << mTimeouts + JLOG (m_journal.debug) << "Timeout(" << mTimeouts << ") pc=" << mPeers.size () << " acquiring " << mHash; onTimer (false, sl); } @@ -99,7 +100,9 @@ void PeerSet::invokeOnTimer () setTimer (); } -void PeerSet::timerEntry (std::weak_ptr wptr, const boost::system::error_code& result) +void PeerSet::timerEntry ( + std::weak_ptr wptr, const boost::system::error_code& result, + beast::Journal j) { if (result == boost::asio::error::operation_aborted) return; @@ -125,7 +128,7 @@ void PeerSet::timerEntry (std::weak_ptr wptr, const boost::system::erro if (jc > 4) { - WriteLog (lsDEBUG, InboundLedger) << "Deferring PeerSet timer due to load"; + JLOG (j.debug) << "Deferring PeerSet timer due to load"; ptr->setTimer (); } else diff --git a/src/ripple/protocol/tests/STAmount.test.cpp b/src/ripple/protocol/tests/STAmount.test.cpp index 4a12fe480d..866d5f69a7 100644 --- a/src/ripple/protocol/tests/STAmount.test.cpp +++ b/src/ripple/protocol/tests/STAmount.test.cpp @@ -369,7 +369,7 @@ public: if (divide (STAmount (noIssue(), 60), STAmount (3), noIssue()).getText () != "20") { - WriteLog (lsFATAL, STAmount) << "60/3 = " << + log << "60/3 = " << divide (STAmount (noIssue(), 60), STAmount (3), noIssue()).getText (); fail ("STAmount divide fail"); @@ -414,7 +414,7 @@ public: if (b.getuint64 () != r) { - WriteLog (lsFATAL, STAmount) << r << " != " << b.getuint64 () << " " << b.ToString (16); + log << r << " != " << b.getuint64 () << " " << b.ToString (16); fail ("setull64/getull64 failure"); } else @@ -535,35 +535,35 @@ public: STAmount oneThird1 = divRound (one, three, noIssue(), false); STAmount oneThird2 = divide (one, three, noIssue()); STAmount oneThird3 = divRound (one, three, noIssue(), true); - WriteLog (lsINFO, STAmount) << oneThird1; - WriteLog (lsINFO, STAmount) << oneThird2; - WriteLog (lsINFO, STAmount) << oneThird3; + log << oneThird1; + log << oneThird2; + log << oneThird3; STAmount twoThird1 = divRound (two, three, noIssue(), false); STAmount twoThird2 = divide (two, three, noIssue()); STAmount twoThird3 = divRound (two, three, noIssue(), true); - WriteLog (lsINFO, STAmount) << twoThird1; - WriteLog (lsINFO, STAmount) << twoThird2; - WriteLog (lsINFO, STAmount) << twoThird3; + log << twoThird1; + log << twoThird2; + log << twoThird3; STAmount oneA = mulRound (oneThird1, three, noIssue(), false); STAmount oneB = multiply (oneThird2, three, noIssue()); STAmount oneC = mulRound (oneThird3, three, noIssue(), true); - WriteLog (lsINFO, STAmount) << oneA; - WriteLog (lsINFO, STAmount) << oneB; - WriteLog (lsINFO, STAmount) << oneC; + log << oneA; + log << oneB; + log << oneC; STAmount fourThirdsB = twoThird2 + twoThird2; - WriteLog (lsINFO, STAmount) << fourThirdsA; - WriteLog (lsINFO, STAmount) << fourThirdsB; - WriteLog (lsINFO, STAmount) << fourThirdsC; + log << fourThirdsA; + log << fourThirdsB; + log << fourThirdsC; STAmount dripTest1 = mulRound (twoThird2, two, xrpIssue (), false); STAmount dripTest2 = multiply (twoThird2, two, xrpIssue ()); STAmount dripTest3 = mulRound (twoThird2, two, xrpIssue (), true); - WriteLog (lsINFO, STAmount) << dripTest1; - WriteLog (lsINFO, STAmount) << dripTest2; - WriteLog (lsINFO, STAmount) << dripTest3; + log << dripTest1; + log << dripTest2; + log << dripTest3; #endif } diff --git a/src/ripple/protocol/tests/STObject.test.cpp b/src/ripple/protocol/tests/STObject.test.cpp index 3115d17059..9976e3dec8 100644 --- a/src/ripple/protocol/tests/STObject.test.cpp +++ b/src/ripple/protocol/tests/STObject.test.cpp @@ -134,8 +134,8 @@ public: if (object1.getSerializer () == object2.getSerializer ()) { - WriteLog (lsINFO, STObject) << "O1: " << object1.getJson (0); - WriteLog (lsINFO, STObject) << "O2: " << object2.getJson (0); + log << "O1: " << object1.getJson (0); + log << "O2: " << object2.getJson (0); fail ("STObject error 4"); } else diff --git a/src/ripple/rpc/Context.h b/src/ripple/rpc/Context.h index d8c34fa150..8efd4d57d0 100644 --- a/src/ripple/rpc/Context.h +++ b/src/ripple/rpc/Context.h @@ -26,6 +26,8 @@ #include #include +#include + namespace ripple { class Application; @@ -37,6 +39,7 @@ namespace RPC { /** The context of information needed to call an RPC. */ struct Context { + beast::Journal j; Json::Value params; Application& app; Resource::Charge& loadType; diff --git a/src/ripple/rpc/handlers/BookOffers.cpp b/src/ripple/rpc/handlers/BookOffers.cpp index fa58b7b0db..af78460416 100644 --- a/src/ripple/rpc/handlers/BookOffers.cpp +++ b/src/ripple/rpc/handlers/BookOffers.cpp @@ -79,7 +79,7 @@ Json::Value doBookOffers (RPC::Context& context) if (!to_currency (pay_currency, taker_pays [jss::currency].asString ())) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; + JLOG (context.j.info) << "Bad taker_pays currency."; return RPC::make_error (rpcSRC_CUR_MALFORMED, "Invalid field 'taker_pays.currency', bad currency."); } @@ -88,7 +88,7 @@ Json::Value doBookOffers (RPC::Context& context) if (!to_currency (get_currency, taker_gets [jss::currency].asString ())) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_gets currency."; + JLOG (context.j.info) << "Bad taker_gets currency."; return RPC::make_error (rpcDST_AMT_MALFORMED, "Invalid field 'taker_gets.currency', bad currency."); } @@ -168,7 +168,7 @@ Json::Value doBookOffers (RPC::Context& context) if (pay_currency == get_currency && pay_issuer == get_issuer) { - WriteLog (lsINFO, RPCHandler) << "taker_gets same as taker_pays."; + JLOG (context.j.info) << "taker_gets same as taker_pays."; return RPC::make_error (rpcBAD_MARKET); } diff --git a/src/ripple/rpc/handlers/Internal.cpp b/src/ripple/rpc/handlers/Internal.cpp index 16064ea64d..d22b860c4a 100644 --- a/src/ripple/rpc/handlers/Internal.cpp +++ b/src/ripple/rpc/handlers/Internal.cpp @@ -45,10 +45,10 @@ Json::Value doInternal (RPC::Context& context) { if (name == h->name_) { - WriteLog (lsWARNING, RPCHandler) + JLOG (context.j.warning) << "Internal command " << name << ": " << params; Json::Value ret = h->handler_ (params); - WriteLog (lsWARNING, RPCHandler) + JLOG (context.j.warning) << "Internal command returns: " << ret; return ret; } diff --git a/src/ripple/rpc/handlers/LedgerRequest.cpp b/src/ripple/rpc/handlers/LedgerRequest.cpp index b80fcee9fc..b580443e58 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 = context.app.logs().journal("RPCHandler"); + auto const j = context.app.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/RipplePathFind.cpp b/src/ripple/rpc/handlers/RipplePathFind.cpp index ae41e554d3..eda995974a 100644 --- a/src/ripple/rpc/handlers/RipplePathFind.cpp +++ b/src/ripple/rpc/handlers/RipplePathFind.cpp @@ -150,7 +150,7 @@ Json::Value doRipplePathFind (RPC::Context& context) && (!saDstAmount.getIssuer () || noAccount() == saDstAmount.getIssuer ()))) { - WriteLog (lsINFO, RPCHandler) << "Bad destination_amount."; + JLOG (context.j.info) << "Bad destination_amount."; jvResult = rpcError (rpcINVALID_PARAMS); } else if ( @@ -161,7 +161,7 @@ Json::Value doRipplePathFind (RPC::Context& context) // Don't allow empty currencies. ) { - WriteLog (lsINFO, RPCHandler) << "Bad source_currencies."; + JLOG (context.j.info) << "Bad source_currencies."; jvResult = rpcError (rpcINVALID_PARAMS); } else @@ -256,7 +256,7 @@ Json::Value doRipplePathFind (RPC::Context& context) jvResult[jss::alternatives] = pathFindResult.second; } - WriteLog (lsDEBUG, RPCHandler) + JLOG (context.j.debug) << "ripple_path_find< " << jvResult; return jvResult; @@ -283,6 +283,8 @@ ripplePathFind (RippleLineCache::pointer const& cache, Json::Value jvArray(Json::arrayValue); + auto j = app.journal ("RPCHandler"); + for (unsigned int i = 0; i != jvSrcCurrencies.size(); ++i) { Json::Value jvSource = jvSrcCurrencies[i]; @@ -298,7 +300,7 @@ ripplePathFind (RippleLineCache::pointer const& cache, || !to_currency( uSrcCurrencyID, jvSource[jss::currency].asString())) { - WriteLog(lsINFO, RPCHandler) << "Bad currency."; + JLOG (j.info) << "Bad currency."; return std::make_pair(false, rpcError(rpcSRC_CUR_MALFORMED)); } @@ -312,7 +314,7 @@ ripplePathFind (RippleLineCache::pointer const& cache, (uSrcIssuerID.isZero() != uSrcCurrencyID.isZero()) || (noAccount() == uSrcIssuerID))) { - WriteLog(lsINFO, RPCHandler) << "Bad issuer."; + JLOG (j.info) << "Bad issuer."; return std::make_pair(false, rpcError(rpcSRC_ISR_MALFORMED)); } @@ -351,7 +353,7 @@ ripplePathFind (RippleLineCache::pointer const& cache, else { spsComputed = paths.object->getFieldPathSet(sfPaths); - WriteLog(lsTRACE, RPCHandler) << "ripple_path_find: Paths: " << + JLOG (j.trace) << "ripple_path_find: Paths: " << spsComputed.getJson(0); } } @@ -364,7 +366,7 @@ ripplePathFind (RippleLineCache::pointer const& cache, app); if (! result) { - WriteLog(lsWARNING, RPCHandler) + JLOG (j.warning) << "ripple_path_find: No paths found."; } else @@ -394,9 +396,10 @@ ripplePathFind (RippleLineCache::pointer const& cache, raDst, // --> Account to deliver to. raSrc, // --> Account sending from. *result, // --> Path set. + app.logs (), &rcInput); - WriteLog(lsWARNING, RPCHandler) + JLOG (j.warning) << "ripple_path_find:" << " saMaxAmount=" << saMaxAmount << " saDstAmount=" << saDstAmount @@ -407,7 +410,8 @@ ripplePathFind (RippleLineCache::pointer const& cache, ! fullLiquidityPath.empty() && (rc.result() == terNO_LINE || rc.result() == tecPATH_PARTIAL)) { - WriteLog(lsDEBUG, PathRequest) + auto jpr = app.journal ("PathRequest"); + JLOG (jpr.debug) << "Trying with an extra path element"; result->push_back(fullLiquidityPath); sandbox.emplace(&*cache->getLedger(), tapNONE); @@ -419,8 +423,9 @@ ripplePathFind (RippleLineCache::pointer const& cache, saDstAmount, // --> Amount to deliver. raDst, // --> Account to deliver to. raSrc, // --> Account sending from. - *result); // --> Path set. - WriteLog(lsDEBUG, PathRequest) + *result, // --> Path set. + app.logs ()); + JLOG (jpr.debug) << "Extra path element gives " << transHuman(rc.result()); } @@ -451,7 +456,7 @@ ripplePathFind (RippleLineCache::pointer const& cache, transResultInfo(rc.result(), strToken, strHuman); - WriteLog(lsDEBUG, RPCHandler) + JLOG (j.debug) << "ripple_path_find: " << strToken << " " << strHuman << " " diff --git a/src/ripple/rpc/handlers/Subscribe.cpp b/src/ripple/rpc/handlers/Subscribe.cpp index 248287f8d7..8c1c228736 100644 --- a/src/ripple/rpc/handlers/Subscribe.cpp +++ b/src/ripple/rpc/handlers/Subscribe.cpp @@ -42,7 +42,7 @@ Json::Value doSubscribe (RPC::Context& context) if (!context.infoSub && !context.params.isMember (jss::url)) { // Must be a JSON-RPC call. - WriteLog (lsINFO, RPCHandler) + JLOG (context.j.info) << "doSubscribe: RPC subscribe requires a url"; return rpcError (rpcINVALID_PARAMS); @@ -71,18 +71,18 @@ Json::Value doSubscribe (RPC::Context& context) if (!ispSub) { - WriteLog (lsDEBUG, RPCHandler) + JLOG (context.j.debug) << "doSubscribe: building: " << strUrl; auto rspSub = make_RPCSub (context.app.getOPs (), context.app.getIOService (), context.app.getJobQueue (), - strUrl, strUsername, strPassword); + strUrl, strUsername, strPassword, context.app.logs ()); ispSub = context.netOps.addRpcSub ( strUrl, std::dynamic_pointer_cast (rspSub)); } else { - WriteLog (lsTRACE, RPCHandler) + JLOG (context.j.trace) << "doSubscribe: reusing: " << strUrl; if (auto rpcSub = std::dynamic_pointer_cast (ispSub)) @@ -108,7 +108,7 @@ Json::Value doSubscribe (RPC::Context& context) } else if (!context.params[jss::streams].isArray ()) { - WriteLog (lsINFO, RPCHandler) + JLOG (context.j.info) << "doSubscribe: streams requires an array."; return rpcError (rpcINVALID_PARAMS); @@ -194,7 +194,7 @@ Json::Value doSubscribe (RPC::Context& context) else { context.netOps.subAccount (ispSub, ids, false); - WriteLog (lsDEBUG, RPCHandler) + JLOG (context.j.debug) << "doSubscribe: accounts: " << ids.size (); } } @@ -235,7 +235,7 @@ Json::Value doSubscribe (RPC::Context& context) || !to_currency (book.in.currency, taker_pays[jss::currency].asString ())) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; + JLOG (context.j.info) << "Bad taker_pays currency."; return rpcError (rpcSRC_CUR_MALFORMED); } @@ -248,7 +248,7 @@ Json::Value doSubscribe (RPC::Context& context) || (!book.in.currency != !book.in.account) || noAccount() == book.in.account) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_pays issuer."; + JLOG (context.j.info) << "Bad taker_pays issuer."; return rpcError (rpcSRC_ISR_MALFORMED); } @@ -258,7 +258,7 @@ Json::Value doSubscribe (RPC::Context& context) || !to_currency (book.out.currency, taker_gets[jss::currency].asString ())) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; + JLOG (context.j.info) << "Bad taker_pays currency."; return rpcError (rpcSRC_CUR_MALFORMED); } @@ -271,7 +271,7 @@ Json::Value doSubscribe (RPC::Context& context) || (!book.out.currency != !book.out.account) || noAccount() == book.out.account) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_gets issuer."; + JLOG (context.j.info) << "Bad taker_gets issuer."; return rpcError (rpcDST_ISR_MALFORMED); } @@ -279,7 +279,7 @@ Json::Value doSubscribe (RPC::Context& context) if (book.in.currency == book.out.currency && book.in.account == book.out.account) { - WriteLog (lsINFO, RPCHandler) + JLOG (context.j.info) << "taker_gets same as taker_pays."; return rpcError (rpcBAD_MARKET); } @@ -296,7 +296,7 @@ Json::Value doSubscribe (RPC::Context& context) if (!isConsistent (book)) { - WriteLog (lsWARNING, RPCHandler) << "Bad market: " << book; + JLOG (context.j.warning) << "Bad market: " << book; return rpcError (rpcBAD_MARKET); } diff --git a/src/ripple/rpc/handlers/Tx.cpp b/src/ripple/rpc/handlers/Tx.cpp index 42824f65de..c6e458db37 100644 --- a/src/ripple/rpc/handlers/Tx.cpp +++ b/src/ripple/rpc/handlers/Tx.cpp @@ -126,7 +126,8 @@ Json::Value doTx (RPC::Context& context) auto rawMeta = lgr->txRead (txn->getID()).second; if (rawMeta) { - auto txMeta = std::make_shared (txn->getID(), lgr->seq(), *rawMeta); + auto txMeta = std::make_shared (txn->getID (), + lgr->seq (), *rawMeta, context.app.journal ("TxMeta")); okay = true; auto meta = txMeta->getJson (0); addPaymentDeliveredAmount (meta, context, txn, txMeta); diff --git a/src/ripple/rpc/handlers/Unsubscribe.cpp b/src/ripple/rpc/handlers/Unsubscribe.cpp index a1c1b62522..0318e78073 100644 --- a/src/ripple/rpc/handlers/Unsubscribe.cpp +++ b/src/ripple/rpc/handlers/Unsubscribe.cpp @@ -149,7 +149,7 @@ Json::Value doUnsubscribe (RPC::Context& context) || !to_currency ( book.in.currency, taker_pays[jss::currency].asString ())) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; + JLOG (context.j.info) << "Bad taker_pays currency."; return rpcError (rpcSRC_CUR_MALFORMED); } // Parse optional issuer. @@ -161,7 +161,7 @@ Json::Value doUnsubscribe (RPC::Context& context) || !isConsistent (book.in) || noAccount() == book.in.account) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_pays issuer."; + JLOG (context.j.info) << "Bad taker_pays issuer."; return rpcError (rpcSRC_ISR_MALFORMED); } @@ -171,7 +171,7 @@ Json::Value doUnsubscribe (RPC::Context& context) || !to_currency (book.out.currency, taker_gets[jss::currency].asString ())) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_pays currency."; + JLOG (context.j.info) << "Bad taker_pays currency."; return rpcError (rpcSRC_CUR_MALFORMED); } @@ -184,14 +184,14 @@ Json::Value doUnsubscribe (RPC::Context& context) || !isConsistent (book.out) || noAccount() == book.out.account) { - WriteLog (lsINFO, RPCHandler) << "Bad taker_gets issuer."; + JLOG (context.j.info) << "Bad taker_gets issuer."; return rpcError (rpcDST_ISR_MALFORMED); } if (book.in == book.out) { - WriteLog (lsINFO, RPCHandler) + JLOG (context.j.info) << "taker_gets same as taker_pays."; return rpcError (rpcBAD_MARKET); } diff --git a/src/ripple/rpc/handlers/ValidationCreate.cpp b/src/ripple/rpc/handlers/ValidationCreate.cpp index afb8952c22..b0a65250c5 100644 --- a/src/ripple/rpc/handlers/ValidationCreate.cpp +++ b/src/ripple/rpc/handlers/ValidationCreate.cpp @@ -40,7 +40,7 @@ Json::Value doValidationCreate (RPC::Context& context) if (!context.params.isMember (jss::secret)) { - WriteLog (lsDEBUG, RPCHandler) << "Creating random validation seed."; + JLOG (context.j.debug) << "Creating random validation seed."; raSeed.setSeedRandom (); // Get a random seed. } diff --git a/src/ripple/rpc/impl/LookupLedger.cpp b/src/ripple/rpc/impl/LookupLedger.cpp index 679a2a0cd3..280fe5dbd7 100644 --- a/src/ripple/rpc/impl/LookupLedger.cpp +++ b/src/ripple/rpc/impl/LookupLedger.cpp @@ -179,7 +179,7 @@ bool isValidated (LedgerMaster& ledgerMaster, ReadView const& ledger, } catch (SHAMapMissingNode const&) { - WriteLog (lsWARNING, RPCHandler) + JLOG (app.journal ("RPCHandler").warning) << "Missing SHANode " << std::to_string (seq); return false; } diff --git a/src/ripple/rpc/impl/RPCHandler.cpp b/src/ripple/rpc/impl/RPCHandler.cpp index 3b0dc8693d..90574deb94 100644 --- a/src/ripple/rpc/impl/RPCHandler.cpp +++ b/src/ripple/rpc/impl/RPCHandler.cpp @@ -119,7 +119,7 @@ error_code_i fillHandler (Context& context, int jc = context.app.getJobQueue ().getJobCountGE (jtCLIENT); if (jc > Tuning::maxJobQueueClients) { - WriteLog (lsDEBUG, RPCHandler) << "Too busy for command: " << jc; + JLOG (context.j.debug) << "Too busy for command: " << jc; return rpcTOO_BUSY; } } @@ -129,8 +129,8 @@ error_code_i fillHandler (Context& context, std::string strCommand = context.params[jss::command].asString (); - WriteLog (lsTRACE, RPCHandler) << "COMMAND:" << strCommand; - WriteLog (lsTRACE, RPCHandler) << "REQUEST:" << context.params; + JLOG (context.j.trace) << "COMMAND:" << strCommand; + JLOG (context.j.trace) << "REQUEST:" << context.params; auto handler = getHandler(strCommand); @@ -143,7 +143,7 @@ error_code_i fillHandler (Context& context, if ((handler->condition_ & NEEDS_NETWORK_CONNECTION) && (context.netOps.getOperatingMode () < NetworkOPs::omSYNCING)) { - WriteLog (lsINFO, RPCHandler) + JLOG (context.j.info) << "Insufficient network mode for RPC: " << context.netOps.strOperatingMode (); @@ -164,7 +164,7 @@ error_code_i fillHandler (Context& context, if (cID + 10 < vID) { - WriteLog (lsDEBUG, RPCHandler) << "Current ledger ID(" << cID << + JLOG (context.j.debug) << "Current ledger ID(" << cID << ") is less than validated ledger ID(" << vID << ")"; return rpcNO_CURRENT; } @@ -192,7 +192,7 @@ Status callMethod ( } catch (std::exception& e) { - WriteLog (lsINFO, RPCHandler) << "Caught throw: " << e.what (); + JLOG (context.j.info) << "Caught throw: " << e.what (); if (context.loadType == Resource::feeReferenceRPC) context.loadType = Resource::feeExceptionRPC; @@ -209,7 +209,7 @@ void getResult ( auto&& result = Json::addObject (object, jss::result); if (auto status = callMethod (context, method, name, result)) { - WriteLog (lsDEBUG, RPCErr) << "rpcError: " << status.toString(); + JLOG (context.j.debug) << "rpcError: " << status.toString(); result[jss::status] = jss::error; result[jss::request] = context.params; } diff --git a/src/ripple/rpc/impl/TransactionSign.cpp b/src/ripple/rpc/impl/TransactionSign.cpp index 69156b4fe0..db799ea8af 100644 --- a/src/ripple/rpc/impl/TransactionSign.cpp +++ b/src/ripple/rpc/impl/TransactionSign.cpp @@ -206,13 +206,14 @@ static Json::Value checkPayment( fullLiquidityPath, app); + auto j = app.journal ("RPCHandler"); if (! result) { - WriteLog (lsDEBUG, RPCHandler) + JLOG (j.debug) << "transactionSign: build_path: No paths found."; return rpcError (rpcNO_PATH); } - WriteLog (lsDEBUG, RPCHandler) + JLOG (j.debug) << "transactionSign: build_path: " << result->getJson (0); @@ -335,6 +336,8 @@ transactionPreProcessImpl ( Application& app, std::shared_ptr ledger) { + auto j = app.journal ("RPCHandler"); + KeyPair keypair; { Json::Value jvResult; @@ -373,7 +376,7 @@ transactionPreProcessImpl ( if (verify && !sle) { // If not offline and did not find account, error. - WriteLog (lsDEBUG, RPCHandler) + JLOG (j.debug) << "transactionSign: Failed to find source account " << "in current ledger: " << toBase58(srcAddressID); @@ -412,7 +415,7 @@ transactionPreProcessImpl ( { if (! sle) { - WriteLog (lsDEBUG, RPCHandler) + JLOG (j.debug) << "transactionSign: Failed to find source account " << "in current ledger: " << toBase58(srcAddressID); @@ -432,7 +435,7 @@ transactionPreProcessImpl ( // XXX Ignore transactions for accounts not created. return rpcError (rpcSRC_ACT_NOT_FOUND); - WriteLog (lsTRACE, RPCHandler) + JLOG (j.trace) << "verify: " << toBase58(calcAccountID(keypair.publicKey)) << " : " << toBase58(srcAddressID); @@ -656,10 +659,11 @@ Json::Value transactionSign ( Application& app, std::shared_ptr ledger) { - WriteLog (lsDEBUG, RPCHandler) << "transactionSign: " << jvRequest; - using namespace detail; + auto j = app.journal ("RPCHandler"); + JLOG (j.debug) << "transactionSign: " << jvRequest; + // Add and amend fields based on the transaction type. SigningForParams signForParams; transactionPreProcessResult preprocResult = transactionPreProcessImpl ( @@ -689,10 +693,12 @@ Json::Value transactionSubmit ( std::shared_ptr ledger, ProcessTransactionFn const& processTransaction) { - WriteLog (lsDEBUG, RPCHandler) << "transactionSubmit: " << jvRequest; - using namespace detail; + auto j = app.journal ("RPCHandler"); + JLOG (j.debug) << "transactionSubmit: " << jvRequest; + + // Add and amend fields based on the transaction type. SigningForParams signForParams; transactionPreProcessResult preprocResult = transactionPreProcessImpl ( @@ -762,7 +768,8 @@ Json::Value transactionSignFor ( Application& app, std::shared_ptr ledger) { - WriteLog (lsDEBUG, RPCHandler) << "transactionSignFor: " << jvRequest; + auto j = app.journal ("RPCHandler"); + JLOG (j.debug) << "transactionSignFor: " << jvRequest; // Verify presence of the signer's account field. const char accountField[] = "account"; @@ -863,7 +870,8 @@ Json::Value transactionSubmitMultiSigned ( std::shared_ptr ledger, ProcessTransactionFn const& processTransaction) { - WriteLog (lsDEBUG, RPCHandler) + auto j = app.journal ("RPCHandler"); + JLOG (j.debug) << "transactionSubmitMultiSigned: " << jvRequest; // When multi-signing, the "Sequence" and "SigningPubKey" fields must @@ -892,7 +900,7 @@ Json::Value transactionSubmitMultiSigned ( if (!sle) { // If did not find account, error. - WriteLog (lsDEBUG, RPCHandler) + JLOG (j.debug) << "transactionSubmitMultiSigned: Failed to find source account " << "in current ledger: " << toBase58(srcAddressID); diff --git a/src/ripple/server/impl/JSONRPCUtil.cpp b/src/ripple/server/impl/JSONRPCUtil.cpp index 2ed356c4ce..838272ae60 100644 --- a/src/ripple/server/impl/JSONRPCUtil.cpp +++ b/src/ripple/server/impl/JSONRPCUtil.cpp @@ -46,12 +46,10 @@ std::string getHTTPHeaderTimestamp () } void HTTPReply ( - int nStatus, std::string const& content, Json::Output const& output) + int nStatus, std::string const& content, Json::Output const& output, beast::Journal j) { - if (ShouldLog (lsTRACE, RPC)) - { - WriteLog (lsTRACE, RPC) << "HTTP Reply " << nStatus << " " << content; - } + JLOG (j.trace) + << "HTTP Reply " << nStatus << " " << content; if (nStatus == 401) { diff --git a/src/ripple/server/impl/JSONRPCUtil.h b/src/ripple/server/impl/JSONRPCUtil.h index d7b0bd5200..8c632b7237 100644 --- a/src/ripple/server/impl/JSONRPCUtil.h +++ b/src/ripple/server/impl/JSONRPCUtil.h @@ -25,7 +25,8 @@ namespace ripple { -void HTTPReply (int nStatus, std::string const& strMsg, Json::Output const&); +void HTTPReply ( + int nStatus, std::string const& strMsg, Json::Output const&, beast::Journal j); } // ripple diff --git a/src/ripple/server/impl/ServerHandlerImp.cpp b/src/ripple/server/impl/ServerHandlerImp.cpp index 1dac0a9e62..2e8d2ffef5 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 (app_.logs().journal("Server")) + , m_journal (app_.journal("Server")) , m_networkOPs (networkOPs) , m_server (HTTP::make_Server( - *this, io_service, app_.logs().journal("Server"))) + *this, io_service, app_.journal("Server"))) , m_jobQueue (jobQueue) { auto const& group (cm.group ("rpc")); @@ -165,7 +165,7 @@ ServerHandlerImp::onRequest (HTTP::Session& session) if (session.port().protocol.count("http") == 0 && session.port().protocol.count("https") == 0) { - HTTPReply (403, "Forbidden", makeOutput (session)); + HTTPReply (403, "Forbidden", makeOutput (session), app_.journal ("RPC")); session.close (true); return; } @@ -174,7 +174,7 @@ ServerHandlerImp::onRequest (HTTP::Session& session) if (! authorized ( session.port(), build_map(session.request().headers))) { - HTTPReply (403, "Forbidden", makeOutput (session)); + HTTPReply (403, "Forbidden", makeOutput (session), app_.journal ("RPC")); session.close (true); return; } @@ -232,6 +232,7 @@ ServerHandlerImp::processRequest ( Output&& output, Suspend const& suspend) { + auto rpcJ = app_.journal ("RPC"); // Move off the webserver thread onto the JobQueue. assert (app_.getJobQueue().getJobForThread()); @@ -243,7 +244,7 @@ ServerHandlerImp::processRequest ( ! jsonRPC || ! jsonRPC.isObject ()) { - HTTPReply (400, "Unable to parse request", output); + HTTPReply (400, "Unable to parse request", output, rpcJ); return; } } @@ -256,12 +257,12 @@ ServerHandlerImp::processRequest ( Json::Value const& method = jsonRPC ["method"]; if (! method) { - HTTPReply (400, "Null method", output); + HTTPReply (400, "Null method", output, rpcJ); return; } if (!method.isString ()) { - HTTPReply (400, "method is not string", output); + HTTPReply (400, "method is not string", output, rpcJ); return; } @@ -292,14 +293,14 @@ ServerHandlerImp::processRequest ( if (usage.disconnect ()) { - HTTPReply (503, "Server is overloaded", output); + HTTPReply (503, "Server is overloaded", output, rpcJ); return; } std::string strMethod = method.asString (); if (strMethod.empty()) { - HTTPReply (400, "method is empty", output); + HTTPReply (400, "method is empty", output, rpcJ); return; } @@ -316,7 +317,7 @@ ServerHandlerImp::processRequest ( else if (!params.isArray () || params.size() != 1) { - HTTPReply (400, "params unparseable", output); + HTTPReply (400, "params unparseable", output, rpcJ); return; } else @@ -324,7 +325,7 @@ ServerHandlerImp::processRequest ( params = std::move (params[0u]); if (!params.isObject()) { - HTTPReply (400, "params unparseable", output); + HTTPReply (400, "params unparseable", output, rpcJ); return; } } @@ -336,7 +337,7 @@ ServerHandlerImp::processRequest ( // VFALCO TODO Needs implementing // FIXME Needs implementing // XXX This needs rate limiting to prevent brute forcing password. - HTTPReply (403, "Forbidden", output); + HTTPReply (403, "Forbidden", output, rpcJ); return; } @@ -346,13 +347,13 @@ ServerHandlerImp::processRequest ( // Provide the JSON-RPC method as the field "command" in the request. params[jss::command] = strMethod; - WriteLog (lsTRACE, RPCHandler) + JLOG (m_journal.trace) << "doRpcCommand:" << strMethod << ":" << params; auto const start (std::chrono::high_resolution_clock::now ()); RPC::Context context { - params, app_, loadType, m_networkOPs, app_.getLedgerMaster(), role, + m_journal, params, app_, loadType, m_networkOPs, app_.getLedgerMaster(), role, {app_, suspend, "RPC-Coroutine"}}; std::string response; @@ -371,7 +372,7 @@ ServerHandlerImp::processRequest ( { result[jss::status] = jss::error; result[jss::request] = params; - WriteLog (lsDEBUG, RPCErr) << + JLOG (m_journal.debug) << "rpcError: " << result [jss::error] << ": " << result [jss::error_message]; } @@ -406,7 +407,7 @@ ServerHandlerImp::processRequest ( m_journal.debug << "Reply: " << response.substr (0, maxSize); } - HTTPReply (200, response, output); + HTTPReply (200, response, output, rpcJ); } //------------------------------------------------------------------------------ diff --git a/src/ripple/shamap/Family.h b/src/ripple/shamap/Family.h index 7c23e113f4..e3200a5ec8 100644 --- a/src/ripple/shamap/Family.h +++ b/src/ripple/shamap/Family.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_SHAMAP_FAMILY_H_INCLUDED #define RIPPLE_SHAMAP_FAMILY_H_INCLUDED +#include #include #include #include diff --git a/src/ripple/shamap/SHAMapTreeNode.h b/src/ripple/shamap/SHAMapTreeNode.h index aae9a33074..b55cd46e79 100644 --- a/src/ripple/shamap/SHAMapTreeNode.h +++ b/src/ripple/shamap/SHAMapTreeNode.h @@ -81,7 +81,7 @@ public: static std::shared_ptr make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat format, - uint256 const& hash, bool hashValid); + uint256 const& hash, bool hashValid, beast::Journal j); // debugging #ifdef BEAST_DEBUG @@ -125,7 +125,8 @@ public: friend std::shared_ptr SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, - SHANodeFormat format, uint256 const& hash, bool hashValid); + SHANodeFormat format, uint256 const& hash, bool hashValid, + beast::Journal j); }; // SHAMapTreeNode represents a leaf, and may eventually be renamed to reflect that. diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index 09a3434f5c..4bb605fd38 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -176,7 +176,7 @@ SHAMap::fetchNodeFromDB (uint256 const& hash) const try { node = SHAMapAbstractNode::make(obj->getData(), - 0, snfPREFIX, hash, true); + 0, snfPREFIX, hash, true, f_.journal()); if (node) canonicalize (hash, node); } @@ -206,7 +206,8 @@ SHAMap::checkFilter(uint256 const& hash, SHAMapNodeID const& id, Blob nodeData; if (filter->haveNode (id, hash, nodeData)) { - node = SHAMapAbstractNode::make(nodeData, 0, snfPREFIX, hash, true); + node = SHAMapAbstractNode::make( + nodeData, 0, snfPREFIX, hash, true, f_.journal ()); if (node) { filter->gotNode (true, id, hash, nodeData, node->getType ()); @@ -381,7 +382,8 @@ SHAMap::descendAsync (SHAMapInnerNode* parent, int branch, if (!obj) return nullptr; - ptr = SHAMapAbstractNode::make(obj->getData(), 0, snfPREFIX, hash, true); + ptr = SHAMapAbstractNode::make( + obj->getData(), 0, snfPREFIX, hash, true, f_.journal ()); if (ptr && backed_) canonicalize (hash, ptr); diff --git a/src/ripple/shamap/impl/SHAMapSync.cpp b/src/ripple/shamap/impl/SHAMapSync.cpp index 9200e1a83e..d004912000 100644 --- a/src/ripple/shamap/impl/SHAMapSync.cpp +++ b/src/ripple/shamap/impl/SHAMapSync.cpp @@ -418,7 +418,8 @@ SHAMapAddNode SHAMap::addRootNode (Blob const& rootNode, } assert (seq_ >= 1); - auto node = SHAMapAbstractNode::make(rootNode, 0, format, uZero, false); + auto node = SHAMapAbstractNode::make( + rootNode, 0, format, uZero, false, f_.journal ()); if (!node || !node->isValid ()) return SHAMapAddNode::invalid (); @@ -458,7 +459,8 @@ SHAMapAddNode SHAMap::addRootNode (uint256 const& hash, Blob const& rootNode, SH } assert (seq_ >= 1); - auto node = SHAMapAbstractNode::make(rootNode, 0, format, uZero, false); + auto node = SHAMapAbstractNode::make( + rootNode, 0, format, uZero, false, f_.journal ()); if (!node || !node->isValid() || node->getNodeHash () != hash) return SHAMapAddNode::invalid (); @@ -535,7 +537,8 @@ SHAMap::addKnownNode (const SHAMapNodeID& node, Blob const& rawNode, return SHAMapAddNode::invalid (); } - auto newNode = SHAMapAbstractNode::make(rawNode, 0, snfWIRE, uZero, false); + auto newNode = SHAMapAbstractNode::make( + rawNode, 0, snfWIRE, uZero, false, f_.journal ()); if (!newNode || !newNode->isValid() || childHash != newNode->getNodeHash ()) { diff --git a/src/ripple/shamap/impl/SHAMapTreeNode.cpp b/src/ripple/shamap/impl/SHAMapTreeNode.cpp index c1f5640877..5007b4830f 100644 --- a/src/ripple/shamap/impl/SHAMapTreeNode.cpp +++ b/src/ripple/shamap/impl/SHAMapTreeNode.cpp @@ -74,7 +74,7 @@ SHAMapTreeNode::SHAMapTreeNode (std::shared_ptr const& item, std::shared_ptr SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat format, - uint256 const& hash, bool hashValid) + uint256 const& hash, bool hashValid, beast::Journal j) { if (format == snfWIRE) { @@ -181,7 +181,7 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f { if (rawNode.size () < 4) { - WriteLog (lsINFO, SHAMapNodeID) << "size < 4"; + JLOG (j.info) << "size < 4"; throw std::runtime_error ("invalid P node"); } @@ -214,7 +214,7 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f if (u.isZero ()) { - WriteLog (lsINFO, SHAMapNodeID) << "invalid PLN node"; + JLOG (j.info) << "invalid PLN node"; throw std::runtime_error ("invalid PLN node"); } @@ -257,7 +257,7 @@ SHAMapAbstractNode::make(Blob const& rawNode, std::uint32_t seq, SHANodeFormat f } else { - WriteLog (lsINFO, SHAMapNodeID) << "Unknown node prefix " << std::hex << prefix << std::dec; + JLOG (j.info) << "Unknown node prefix " << std::hex << prefix << std::dec; throw std::runtime_error ("invalid node prefix"); } } diff --git a/src/ripple/shamap/tests/SHAMap.test.cpp b/src/ripple/shamap/tests/SHAMap.test.cpp index eaa2df4add..378027c7ee 100644 --- a/src/ripple/shamap/tests/SHAMap.test.cpp +++ b/src/ripple/shamap/tests/SHAMap.test.cpp @@ -51,7 +51,6 @@ public: testcase ("add/traverse"); beast::Journal const j; // debug journal - tests::TestFamily f(j); // h3 and h4 differ only in the leaf, same terminal node (level 19) diff --git a/src/ripple/shamap/tests/SHAMapSync.test.cpp b/src/ripple/shamap/tests/SHAMapSync.test.cpp index 094641b0da..8f1fb7377e 100644 --- a/src/ripple/shamap/tests/SHAMapSync.test.cpp +++ b/src/ripple/shamap/tests/SHAMapSync.test.cpp @@ -99,7 +99,6 @@ public: srand (seed); beast::Journal const j; // debug journal - TestFamily f(j); SHAMap source (SHAMapType::FREE, f); SHAMap destination (SHAMapType::FREE, f); diff --git a/src/ripple/shamap/tests/common.h b/src/ripple/shamap/tests/common.h index e58af676ee..56de81c889 100644 --- a/src/ripple/shamap/tests/common.h +++ b/src/ripple/shamap/tests/common.h @@ -46,7 +46,6 @@ private: beast::Journal j_; public: - explicit TestFamily (beast::Journal j) : treecache_ ("TreeNodeCache", 65536, 60, clock_, j) , fullbelow_ ("full_below", clock_) diff --git a/src/ripple/websocket/AutoSocket.h b/src/ripple/websocket/AutoSocket.h index 54b06f0f2a..e390cf5231 100644 --- a/src/ripple/websocket/AutoSocket.h +++ b/src/ripple/websocket/AutoSocket.h @@ -46,22 +46,32 @@ public: using callback = std::function ; public: - AutoSocket (boost::asio::io_service& s, boost::asio::ssl::context& c) + AutoSocket (boost::asio::io_service& s, boost::asio::ssl::context& c, beast::Journal j) : mSecure (false) , mBuffer (4) + , j_ (j) { mSocket = std::make_shared (s, c); } AutoSocket ( boost::asio::io_service& s, boost::asio::ssl::context& c, - bool secureOnly, bool plainOnly) + bool secureOnly, bool plainOnly, beast::Journal j) : mSecure (secureOnly) , mBuffer ((plainOnly || secureOnly) ? 0 : 4) + , j_ (j) { mSocket = std::make_shared (s, c); } + // swd TBD try remove this constructor + // This needs to use `deprecatedLogs` or a change is needed + // in websocket_02 (which breaks leveling) + AutoSocket ( + boost::asio::io_service& s, boost::asio::ssl::context& c, + bool secureOnly, bool plainOnly) + : AutoSocket (s, c, secureOnly, plainOnly, ripple::deprecatedLogs().journal ("AutoSocket")){} + boost::asio::io_service& get_io_service () noexcept { return mSocket->get_io_service (); @@ -121,14 +131,14 @@ public: static bool rfc2818_verify (std::string const& domain, bool preverified, - boost::asio::ssl::verify_context& ctx) + boost::asio::ssl::verify_context& ctx, beast::Journal j) { using namespace ripple; if (boost::asio::ssl::rfc2818_verification (domain) (preverified, ctx)) return true; - WriteLog (lsWARNING, AutoSocket) << + JLOG (j.warning) << "Outbound SSL connection to " << domain << " fails certificate verification"; return false; @@ -143,7 +153,7 @@ public: // XXX Verify semantics of RFC 2818 are what we want. mSocket->set_verify_callback ( std::bind (&rfc2818_verify, strDomain, - std::placeholders::_1, std::placeholders::_2), ec); + std::placeholders::_1, std::placeholders::_2, j_), ec); return ec; } @@ -316,7 +326,7 @@ protected: if (ec) { - WriteLog (lsWARNING, AutoSocket) << + JLOG (j_.warning) << "Handle autodetect error: " << ec; cbFunc (ec); } @@ -329,14 +339,14 @@ protected: || ((mBuffer[3] < 127) && (mBuffer[3] > 31)))) { // not ssl - WriteLog (lsTRACE, AutoSocket) << "non-SSL"; + JLOG (j_.trace) << "non-SSL"; mSecure = false; cbFunc (ec); } else { // ssl - WriteLog (lsTRACE, AutoSocket) << "SSL"; + JLOG (j_.trace) << "SSL"; mSecure = true; mSocket->async_handshake (ssl_socket::server, cbFunc); } @@ -346,6 +356,7 @@ private: socket_ptr mSocket; bool mSecure; std::vector mBuffer; + beast::Journal j_; }; #endif diff --git a/src/ripple/websocket/Connection.h b/src/ripple/websocket/Connection.h index da311f3977..d46cc8f2d2 100644 --- a/src/ripple/websocket/Connection.h +++ b/src/ripple/websocket/Connection.h @@ -121,6 +121,7 @@ private: weak_connection_ptr m_connection; int pingFreq_; + beast::Journal j_; }; template @@ -144,6 +145,7 @@ ConnectionImpl ::ConnectionImpl ( , m_handler (handler) , m_connection (cpConnection) , pingFreq_ (app.config ().WEBSOCKET_PING_FREQ) + , j_ (app.journal ("ConnectionImpl")) { // VFALCO Disabled since it might cause hangs pingFreq_ = 0; @@ -159,7 +161,7 @@ template void ConnectionImpl ::rcvMessage ( message_ptr const& msg, bool& msgRejected, bool& runQueue) { - WriteLog (lsWARNING, ConnectionImpl) + JLOG (j_.warning) << "WebSocket: rcvMessage"; ScopedLockType sl (m_receiveQueueMutex); @@ -279,7 +281,7 @@ Json::Value ConnectionImpl ::invokeCommand ( else { RPC::Context context { - jvRequest, app_, loadType, m_netOPs, app_.getLedgerMaster(), + app_.journal ("RPCHandler"), jvRequest, app_, loadType, m_netOPs, app_.getLedgerMaster(), role, {app_, suspend, "WSClient::command"}, this->shared_from_this ()}; RPC::doCommand (context, jvResult[jss::result]); @@ -335,7 +337,7 @@ void ConnectionImpl ::preDestroy () template void ConnectionImpl ::send (Json::Value const& jvObj, bool broadcast) { - WriteLog (lsWARNING, ConnectionImpl) + JLOG (j_.warning) << "WebSocket: sending '" << to_string (jvObj); connection_ptr ptr = m_connection.lock (); @@ -346,7 +348,7 @@ void ConnectionImpl ::send (Json::Value const& jvObj, bool broadcast) template void ConnectionImpl ::disconnect () { - WriteLog (lsWARNING, ConnectionImpl) + JLOG (j_.warning) << "WebSocket: disconnecting"; connection_ptr ptr = m_connection.lock (); diff --git a/src/ripple/websocket/Handler.h b/src/ripple/websocket/Handler.h index 06c248bb38..322671d5f8 100644 --- a/src/ripple/websocket/Handler.h +++ b/src/ripple/websocket/Handler.h @@ -77,6 +77,7 @@ private: beast::insight::Event rpc_size_; beast::insight::Event rpc_time_; ServerDescription desc_; + beast::Journal j_; protected: // VFALCO TODO Make this private. @@ -90,6 +91,7 @@ public: HandlerImpl (ServerDescription const& desc) : app_ (desc.app) , desc_ (desc) + , j_ (app_.journal ("HandlerLog")) { auto const& group (desc_.collectorManager.group ("rpc")); rpc_requests_ = group->make_counter ("requests"); @@ -125,7 +127,8 @@ public: { try { - WriteLog (broadcast ? lsTRACE : lsDEBUG, HandlerLog) + auto& jm = broadcast ? j_.trace : j_.debug; + JLOG (jm) << "Ws:: Sending '" << strMessage << "'"; cpClient->send (strMessage); @@ -161,7 +164,7 @@ public: cpClient->terminate ({}); try { - WriteLog (lsDEBUG, HandlerLog) << + JLOG (j_.debug) << "Ws:: ping_out(" << // TODO(tom): re-enable this logging. // cpClient->get_socket ().remote_endpoint ().to_string () @@ -211,7 +214,7 @@ public: assert (result.second); (void) result.second; - WriteLog (lsDEBUG, HandlerLog) << + JLOG (j_.debug) << "Ws:: on_open(" << remoteEndpoint << ")"; } catch (...) @@ -233,7 +236,7 @@ public: } try { - WriteLog (lsDEBUG, HandlerLog) << + JLOG (j_.debug) << "Ws:: on_pong(" << cpClient->get_socket ().remote_endpoint() << ")"; } catch (...) @@ -265,7 +268,7 @@ public: { try { - WriteLog (lsDEBUG, HandlerLog) << + JLOG (j_.debug) << "Ws:: " << reason << "(" << cpClient->get_socket ().remote_endpoint() << ") not found"; @@ -284,7 +287,7 @@ public: ptr->preDestroy (); // Must be done before we return try { - WriteLog (lsDEBUG, HandlerLog) << + JLOG (j_.debug) << "Ws:: " << reason << "(" << cpClient->get_socket ().remote_endpoint () << ") found"; } @@ -326,7 +329,7 @@ public: { try { - WriteLog (lsDEBUG, HandlerLog) << + JLOG (j_.debug) << "Ws:: Rejected(" << cpClient->get_socket().remote_endpoint() << ") '" << mpMessage->get_payload () << "'"; @@ -383,7 +386,7 @@ public: try { - WriteLog (lsDEBUG, HandlerLog) + JLOG (j_.debug) << "Ws:: Receiving(" << cpClient->get_socket ().remote_endpoint () << ") '" << mpMessage->get_payload () << "'"; @@ -435,9 +438,11 @@ public: data->jvRequest = std::move(jvRequest); data->conn = conn; - auto coroutine = [data] (RPC::Suspend const& suspend) { + auto j = app_.journal ("RPCHandler"); + auto coroutine = [data, j] (RPC::Suspend const& suspend) { data->buffer = to_string( - data->conn->invokeCommand(data->jvRequest, suspend)); + data->conn->invokeCommand( + data->jvRequest, suspend)); }; static auto const disableWebsocketsCoroutines = true; auto useCoroutines = disableWebsocketsCoroutines ? diff --git a/src/ripple/websocket/MakeServer.cpp b/src/ripple/websocket/MakeServer.cpp index 37ac73ca6b..1eafc52551 100644 --- a/src/ripple/websocket/MakeServer.cpp +++ b/src/ripple/websocket/MakeServer.cpp @@ -32,7 +32,7 @@ std::unique_ptr makeServer (ServerDescription const& desc) if (version.empty()) version = WebSocket02::versionName(); - WriteLog (lsWARNING, WebSocket) << "Websocket version " << version; + JLOG (desc.app.journal("WebSocket").warning) << "Websocket version " << version; if (version == WebSocket02::versionName()) return makeServer02 (desc); assert (version == "04"); diff --git a/src/ripple/websocket/Server.h b/src/ripple/websocket/Server.h index aee44b2c47..42864be139 100644 --- a/src/ripple/websocket/Server.h +++ b/src/ripple/websocket/Server.h @@ -40,6 +40,7 @@ private: ServerDescription desc_; LockType m_endpointLock; + beast::Journal j_; typename WebSocket::EndpointPtr m_endpoint; public: @@ -47,6 +48,7 @@ public: : beast::Stoppable (WebSocket::versionName(), desc.source) , Thread ("websocket") , desc_(desc) + , j_ (desc.app.journal ("WebSocket")) { startThread (); } @@ -59,7 +61,7 @@ public: private: void run () override { - WriteLog (lsWARNING, WebSocket) + JLOG (j_.warning) << "Websocket: creating endpoint " << desc_.port; auto handler = WebSocket::makeHandler (desc_); @@ -68,7 +70,7 @@ private: m_endpoint = WebSocket::makeEndpoint (std::move (handler)); } - WriteLog (lsWARNING, WebSocket) + JLOG (j_.warning) << "Websocket: listening on " << desc_.port; listen(); @@ -77,17 +79,17 @@ private: m_endpoint.reset(); } - WriteLog (lsWARNING, WebSocket) + JLOG (j_.warning) << "Websocket: finished listening on " << desc_.port; stopped (); - WriteLog (lsWARNING, WebSocket) + JLOG (j_.warning) << "Websocket: stopped on " << desc_.port; } void onStop () override { - WriteLog (lsWARNING, WebSocket) + JLOG (j_.warning) << "Websocket: onStop " << desc_.port; typename WebSocket::EndpointPtr endpoint; diff --git a/src/ripple/websocket/WebSocket02.cpp b/src/ripple/websocket/WebSocket02.cpp index 1b0d200609..33a334fd34 100644 --- a/src/ripple/websocket/WebSocket02.cpp +++ b/src/ripple/websocket/WebSocket02.cpp @@ -111,12 +111,12 @@ void Server ::listen() } catch (std::exception const& e) { - WriteLog (lsWARNING, Server) << "websocketpp exception: " + JLOG (j_.warning) << "websocketpp exception: " << e.what (); static const int maxRetries = 10; if (maxRetries && i >= maxRetries) { - WriteLog (lsWARNING, Server) + JLOG (j_.warning) << "websocketpp exceeded max retries: " << i; break; } diff --git a/src/ripple/websocket/WebSocket04.cpp b/src/ripple/websocket/WebSocket04.cpp index 2c961b20f0..5ce9e1af82 100644 --- a/src/ripple/websocket/WebSocket04.cpp +++ b/src/ripple/websocket/WebSocket04.cpp @@ -141,7 +141,7 @@ void Server ::listen() m_endpoint->listen (desc_.port.ip, desc_.port.port); m_endpoint->start_accept(); auto c = m_endpoint->get_io_service ().run (); - WriteLog (lsWARNING, WebSocket) + JLOG (j_.warning) << "Server run with: '" << c; }