Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ximinez committed Aug 16, 2024
1 parent 8dc67cc commit adf11c0
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 66 deletions.
13 changes: 9 additions & 4 deletions src/ripple/app/consensus/RCLConsensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 4 additions & 2 deletions src/ripple/app/consensus/RCLValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions src/ripple/app/ledger/impl/InboundLedger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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";
});
}

Expand Down
6 changes: 4 additions & 2 deletions src/ripple/app/ledger/impl/InboundLedgers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ class InboundLedgersImp : public InboundLedgers
if (ledger->gotData(std::weak_ptr<Peer>(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;
Expand Down
64 changes: 32 additions & 32 deletions src/ripple/app/ledger/impl/LedgerMaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ class ScopedUnlock
as a local stack object, rather than creating on the heap.
*/
ScopedUnlock(std::unique_lock<MutexType>& lock, beast::Journal j)
// explicit ScopedUnlock(std::unique_lock<MutexType>& lock) : lock_(lock)
: lock_(lock)
, j_(j)
// explicit ScopedUnlock(std::unique_lock<MutexType>& lock) :
// lock_(lock)
: lock_(lock), j_(j)
{
assert(lock_.owns_lock());
lock_.unlock();
Expand Down Expand Up @@ -1158,9 +1158,9 @@ LedgerMaster::checkAccept(std::shared_ptr<Ledger const> 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();
Expand Down Expand Up @@ -1188,14 +1188,15 @@ LedgerMaster::checkAccept(std::shared_ptr<Ledger const> 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;
}
Expand All @@ -1209,24 +1210,25 @@ LedgerMaster::checkAccept(std::shared_ptr<Ledger const> 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.
auto const vals = app_.getValidations().getTrustedForLedger(
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))
{
Expand All @@ -1239,24 +1241,23 @@ LedgerMaster::checkAccept(std::shared_ptr<Ledger const> 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;
constexpr std::size_t cutoffPercent = 60;
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
Expand Down Expand Up @@ -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";
{
Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
6 changes: 4 additions & 2 deletions src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,8 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& 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) {
Expand All @@ -1360,7 +1361,8 @@ NetworkOPsImp::apply(std::unique_lock<std::mutex>& batchLock)
return changed;
});
}
JLOG(m_journal.debug()) << "LedgerMasterLock std::lock peekMutex unlock3";
JLOG(m_journal.debug())
<< "LedgerMasterLock std::lock peekMutex unlock3";
if (changed)
reportFeeChange();

Expand Down
12 changes: 5 additions & 7 deletions src/ripple/consensus/ConsensusProposal.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include <ripple/protocol/HashPrefix.h>
#include <ripple/protocol/jss.h>
#include <cstdint>
#include <sstream>
#include <optional>
#include <sstream>

namespace ripple {
/** Represents a proposed position taken during a round of consensus.
Expand Down Expand Up @@ -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();
}

Expand Down
8 changes: 4 additions & 4 deletions src/ripple/core/Job.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 9 additions & 11 deletions src/ripple/protocol/STValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,15 @@ class STValidation final : public STObject, public CountedObject<STValidation>
{
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();
}

Expand Down

0 comments on commit adf11c0

Please sign in to comment.