From 4102717caed6df90fc9651fe2bf45927fce982b8 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Fri, 16 Aug 2024 18:35:06 -0400 Subject: [PATCH] Fix formatting --- src/ripple/app/consensus/RCLConsensus.cpp | 13 ++-- src/ripple/app/consensus/RCLValidations.cpp | 6 +- src/ripple/app/ledger/impl/InboundLedger.cpp | 6 +- src/ripple/app/ledger/impl/InboundLedgers.cpp | 6 +- src/ripple/app/ledger/impl/LedgerMaster.cpp | 64 +++++++++---------- src/ripple/app/misc/NetworkOPs.cpp | 6 +- src/ripple/consensus/ConsensusProposal.h | 12 ++-- src/ripple/core/Job.h | 8 +-- src/ripple/protocol/STValidation.h | 20 +++--- 9 files changed, 75 insertions(+), 66 deletions(-) diff --git a/src/ripple/app/consensus/RCLConsensus.cpp b/src/ripple/app/consensus/RCLConsensus.cpp index 2f0b6f0e896..ecf30d0d84d 100644 --- a/src/ripple/app/consensus/RCLConsensus.cpp +++ b/src/ripple/app/consensus/RCLConsensus.cpp @@ -135,11 +135,15 @@ RCLConsensus::Adaptor::acquireLedger(LedgerHash const& hash) acquiringLedger_ = hash; app_.getJobQueue().addJob( - jtADVANCE1, "getConsensusLedger1", [id = hash, &app = app_, this]() { - JLOG(j_.debug()) << "JOB advanceLedger getConsensusLedger1 started"; + jtADVANCE1, + "getConsensusLedger1", + [id = hash, &app = app_, this]() { + JLOG(j_.debug()) + << "JOB advanceLedger getConsensusLedger1 started"; app.getInboundLedgers().acquire( id, 0, InboundLedger::Reason::CONSENSUS); - JLOG(j_.debug()) << "JOB advanceLedger getConsensusLedger1 finishing"; + JLOG(j_.debug()) + << "JOB advanceLedger getConsensusLedger1 finishing"; }); } return std::nullopt; @@ -639,7 +643,8 @@ RCLConsensus::Adaptor::doAccept( // Build new open ledger std::unique_lock lock{app_.getMasterMutex(), std::defer_lock}; - std::unique_lock sl{ledgerMaster_.peekMutex("doAccept"), std::defer_lock}; + std::unique_lock sl{ + ledgerMaster_.peekMutex("doAccept"), std::defer_lock}; JLOG(j_.debug()) << "LedgerMasterLock std::lock peekMutex lock2"; std::lock(lock, sl); diff --git a/src/ripple/app/consensus/RCLValidations.cpp b/src/ripple/app/consensus/RCLValidations.cpp index a7e176bdceb..386a92a26db 100644 --- a/src/ripple/app/consensus/RCLValidations.cpp +++ b/src/ripple/app/consensus/RCLValidations.cpp @@ -136,10 +136,12 @@ RCLValidationsAdaptor::acquire(LedgerHash const& hash) app_.getJobQueue().addJob( jtADVANCE2, "getConsensusLedger2", [pApp, hash, this]() { - JLOG(j_.debug()) << "JOB advanceLedger getConsensusLedger2 started"; + JLOG(j_.debug()) + << "JOB advanceLedger getConsensusLedger2 started"; pApp->getInboundLedgers().acquire( hash, 0, InboundLedger::Reason::CONSENSUS); - JLOG(j_.debug()) << "JOB advanceLedger getConsensusLedger2 finishing"; + JLOG(j_.debug()) + << "JOB advanceLedger getConsensusLedger2 finishing"; }); return std::nullopt; } diff --git a/src/ripple/app/ledger/impl/InboundLedger.cpp b/src/ripple/app/ledger/impl/InboundLedger.cpp index e7e5b1881d3..a01ac950feb 100644 --- a/src/ripple/app/ledger/impl/InboundLedger.cpp +++ b/src/ripple/app/ledger/impl/InboundLedger.cpp @@ -510,7 +510,8 @@ InboundLedger::done() // We hold the PeerSet lock, so must dispatch app_.getJobQueue().addJob( jtLEDGER_DATA, "AcquisitionDone", [self = shared_from_this()]() { - JLOG(self->journal_.debug()) << "JOB ledgerData AcquisitionDone started"; + JLOG(self->journal_.debug()) + << "JOB ledgerData AcquisitionDone started"; if (self->complete_ && !self->failed_) { self->app_.getLedgerMaster().checkAccept(self->getLedger()); @@ -519,7 +520,8 @@ InboundLedger::done() else self->app_.getInboundLedgers().logFailure( self->hash_, self->mSeq); - JLOG(self->journal_.debug()) << "JOB ledgerData AcquisitionDone finished"; + JLOG(self->journal_.debug()) + << "JOB ledgerData AcquisitionDone finished"; }); } diff --git a/src/ripple/app/ledger/impl/InboundLedgers.cpp b/src/ripple/app/ledger/impl/InboundLedgers.cpp index bb8706d0723..f987b2e8c74 100644 --- a/src/ripple/app/ledger/impl/InboundLedgers.cpp +++ b/src/ripple/app/ledger/impl/InboundLedgers.cpp @@ -256,9 +256,11 @@ class InboundLedgersImp : public InboundLedgers if (ledger->gotData(std::weak_ptr(peer), packet)) app_.getJobQueue().addJob( jtLEDGER_DATA, "processLedgerData", [ledger, this]() { - JLOG(j_.debug()) << "JOB ledgerData processLedgerData started"; + JLOG(j_.debug()) + << "JOB ledgerData processLedgerData started"; ledger->runData(); - JLOG(j_.debug()) << "JOB ledgerData processLedgerData finishing"; + JLOG(j_.debug()) + << "JOB ledgerData processLedgerData finishing"; }); return true; diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index d123c1c53c1..745fd5286dd 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -119,9 +119,9 @@ class ScopedUnlock as a local stack object, rather than creating on the heap. */ ScopedUnlock(std::unique_lock& lock, beast::Journal j) -// explicit ScopedUnlock(std::unique_lock& lock) : lock_(lock) - : lock_(lock) - , j_(j) + // explicit ScopedUnlock(std::unique_lock& lock) : + // lock_(lock) + : lock_(lock), j_(j) { assert(lock_.owns_lock()); lock_.unlock(); @@ -1158,9 +1158,9 @@ LedgerMaster::checkAccept(std::shared_ptr const& ledger) return; } - JLOG(m_journal.info()) << "Advancing accepted ledger to " - << ledger->info().seq << " with >= " << minVal - << " validations"; + JLOG(m_journal.info()) + << "Advancing accepted ledger to " << ledger->info().seq + << " with >= " << minVal << " validations"; ledger->setValidated(); ledger->setFull(); @@ -1188,14 +1188,15 @@ LedgerMaster::checkAccept(std::shared_ptr const& ledger) { std::stringstream s; s << "Received fees from validations: (" << fees.size() << ") "; - for (auto const fee1: fees) + for (auto const fee1 : fees) { s << " " << fee1; } stream << s.str(); } fee = fees[fees.size() / 2]; // median - } else + } + else { fee = base; } @@ -1209,16 +1210,17 @@ LedgerMaster::checkAccept(std::shared_ptr const& ledger) // Check if the majority of validators run a higher version rippled // software. If so print a warning. // - // Once the HardenedValidations amendment is enabled, validators include - // their rippled software version in the validation messages of every - // (flag - 1) ledger. We wait for one ledger time before checking the - // version information to accumulate more validation messages. + // Once the HardenedValidations amendment is enabled, validators + // include their rippled software version in the validation messages + // of every (flag - 1) ledger. We wait for one ledger time before + // checking the version information to accumulate more validation + // messages. auto currentTime = app_.timeKeeper().now(); bool needPrint = false; - // The variable upgradeWarningPrevTime_ will be set when and only when - // the warning is printed. + // The variable upgradeWarningPrevTime_ will be set when and only + // when the warning is printed. if (upgradeWarningPrevTime_ == TimeKeeper::time_point()) { // Have not printed the warning before, check if need to print. @@ -1226,7 +1228,7 @@ LedgerMaster::checkAccept(std::shared_ptr const& ledger) ledger->info().parentHash, ledger->info().seq - 1); std::size_t higherVersionCount = 0; std::size_t rippledCount = 0; - for (auto const &v: vals) + for (auto const& v : vals) { if (v->isFieldPresent(sfServerVersion)) { @@ -1239,8 +1241,8 @@ LedgerMaster::checkAccept(std::shared_ptr const& ledger) } // We report only if (1) we have accumulated validation messages // from 90% validators from the UNL, (2) 60% of validators - // running the rippled implementation have higher version numbers, - // and (3) the calculation won't cause divide-by-zero. + // running the rippled implementation have higher version + // numbers, and (3) the calculation won't cause divide-by-zero. if (higherVersionCount > 0 && rippledCount > 0) { constexpr std::size_t reportingPercent = 90; @@ -1248,15 +1250,14 @@ LedgerMaster::checkAccept(std::shared_ptr const& ledger) auto const unlSize{ app_.validators().getQuorumKeys().second.size()}; needPrint = unlSize > 0 && - calculatePercent(vals.size(), unlSize) >= - reportingPercent && - calculatePercent(higherVersionCount, - rippledCount) >= - cutoffPercent; + calculatePercent(vals.size(), unlSize) >= + reportingPercent && + calculatePercent(higherVersionCount, rippledCount) >= + cutoffPercent; } } - // To throttle the warning messages, instead of printing a warning - // every flag ledger, we print every week. + // To throttle the warning messages, instead of printing a warning + // every flag ledger, we print every week. else if (currentTime - upgradeWarningPrevTime_ >= weeks{1}) { // Printed the warning before, and assuming most validators @@ -1561,8 +1562,7 @@ LedgerMaster::tryAdvance() if (!mAdvanceThread && !mValidLedger.empty()) { mAdvanceThread = true; - app_.getJobQueue().addJob(jtADVANCE3, "advanceLedger3", [this]() - { + app_.getJobQueue().addJob(jtADVANCE3, "advanceLedger3", [this]() { JLOG(m_journal.debug()) << "JOB advanceLedger getConsensusLedger3 started"; { @@ -1577,10 +1577,10 @@ LedgerMaster::tryAdvance() { doAdvance(sl); } - catch (std::exception const &ex) + catch (std::exception const& ex) { - JLOG(m_journal.fatal()) << "doAdvance throws: " - << ex.what(); + JLOG(m_journal.fatal()) + << "doAdvance throws: " << ex.what(); } mAdvanceThread = false; @@ -1685,9 +1685,9 @@ LedgerMaster::updatePaths() std::lock_guard ml(m_mutex); if (!pathRequests.requestsPending()) { - JLOG(m_journal.debug()) - << "No path requests left. No need for further updating " - "paths"; + JLOG(m_journal.debug()) << "No path requests left. No need " + "for further updating " + "paths"; --mPathFindThread; mPathLedger.reset(); JLOG(m_journal.debug()) << "LedgerMasterLock unlock20-1"; diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index 67a855ab129..cd5c60d4b45 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -1337,7 +1337,8 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) { std::unique_lock ledgerLock{ m_ledgerMaster.peekMutex("apply"), std::defer_lock}; - JLOG(m_journal.debug()) << "LedgerMasterLock std::lock peekMutex lock3"; + JLOG(m_journal.debug()) + << "LedgerMasterLock std::lock peekMutex lock3"; std::lock(masterLock, ledgerLock); app_.openLedger().modify([&](OpenView& view, beast::Journal j) { @@ -1360,7 +1361,8 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) return changed; }); } - JLOG(m_journal.debug()) << "LedgerMasterLock std::lock peekMutex unlock3"; + JLOG(m_journal.debug()) + << "LedgerMasterLock std::lock peekMutex unlock3"; if (changed) reportFeeChange(); diff --git a/src/ripple/consensus/ConsensusProposal.h b/src/ripple/consensus/ConsensusProposal.h index a56d69c1a4a..00f978ff898 100644 --- a/src/ripple/consensus/ConsensusProposal.h +++ b/src/ripple/consensus/ConsensusProposal.h @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include namespace ripple { /** Represents a proposed position taken during a round of consensus. @@ -200,12 +200,10 @@ class ConsensusProposal { std::stringstream ss; ss << "proposal: previous_ledger: " << previousLedger_ - << " proposal_seq: " << proposeSeq_ - << " position: " << position_ - << " close_time: " << to_string(closeTime_) - << " now: " << to_string(time_) - << " is_bow_out:" << isBowOut() - << " node_id: " << nodeID_; + << " proposal_seq: " << proposeSeq_ << " position: " << position_ + << " close_time: " << to_string(closeTime_) + << " now: " << to_string(time_) << " is_bow_out:" << isBowOut() + << " node_id: " << nodeID_; return ss.str(); } diff --git a/src/ripple/core/Job.h b/src/ripple/core/Job.h index 8d4651f749e..c00e0e9d75b 100644 --- a/src/ripple/core/Job.h +++ b/src/ripple/core/Job.h @@ -65,10 +65,10 @@ enum JobType { jtREQUESTED_TXN, // Reply with requested transactions jtBATCH, // Apply batched transactions jtLEDGER_DATA, // Received data for a ledger we're acquiring - jtADVANCE1, // Advance validated/acquired ledgers 1st caller - jtADVANCE2, // Advance validated/acquired ledgers 2nd caller - jtADVANCE3, // Advance validated/acquired ledgers 3rd caller - jtADVANCE4, // Advance validated/acquired ledgers 4th caller + jtADVANCE1, // Advance validated/acquired ledgers 1st caller + jtADVANCE2, // Advance validated/acquired ledgers 2nd caller + jtADVANCE3, // Advance validated/acquired ledgers 3rd caller + jtADVANCE4, // Advance validated/acquired ledgers 4th caller jtPUBLEDGER, // Publish a fully-accepted ledger jtTXN_DATA, // Fetch a proposed set jtWAL, // Write-ahead logging diff --git a/src/ripple/protocol/STValidation.h b/src/ripple/protocol/STValidation.h index 27d37ac598f..58f69970192 100644 --- a/src/ripple/protocol/STValidation.h +++ b/src/ripple/protocol/STValidation.h @@ -147,17 +147,15 @@ class STValidation final : public STObject, public CountedObject { std::stringstream ss; ss << "validation: " - << " ledger_hash: " << getLedgerHash() - << " consensus_hash: " << getConsensusHash() - << " sign_time: " << to_string(getSignTime()) - << " seen_time: " << to_string(getSeenTime()) - << " signer_public_key: " << getSignerPublic() - << " node_id: " << getNodeID() - << " is_valid: " << isValid() - << " is_full: " << isFull() - << " is_trusted: " << isTrusted() - << " signing_hash: " << getSigningHash() - << " base58: " << toBase58(TokenType::NodePublic, getSignerPublic()); + << " ledger_hash: " << getLedgerHash() + << " consensus_hash: " << getConsensusHash() + << " sign_time: " << to_string(getSignTime()) + << " seen_time: " << to_string(getSeenTime()) + << " signer_public_key: " << getSignerPublic() + << " node_id: " << getNodeID() << " is_valid: " << isValid() + << " is_full: " << isFull() << " is_trusted: " << isTrusted() + << " signing_hash: " << getSigningHash() + << " base58: " << toBase58(TokenType::NodePublic, getSignerPublic()); return ss.str(); }