1#include <xrpld/app/consensus/RCLValidations.h>
2#include <xrpld/app/ledger/Ledger.h>
3#include <xrpld/app/ledger/LedgerMaster.h>
4#include <xrpld/app/ledger/LedgerReplayer.h>
5#include <xrpld/app/ledger/OpenLedger.h>
6#include <xrpld/app/ledger/PendingSaves.h>
7#include <xrpld/app/main/Application.h>
8#include <xrpld/app/misc/SHAMapStore.h>
9#include <xrpld/app/misc/Transaction.h>
10#include <xrpld/app/misc/TxQ.h>
11#include <xrpld/app/misc/ValidatorList.h>
12#include <xrpld/app/paths/PathRequests.h>
13#include <xrpld/core/TimeKeeper.h>
14#include <xrpld/overlay/Overlay.h>
15#include <xrpld/overlay/Peer.h>
17#include <xrpl/basics/Log.h>
18#include <xrpl/basics/MathUtilities.h>
19#include <xrpl/basics/UptimeClock.h>
20#include <xrpl/basics/contract.h>
21#include <xrpl/basics/safe_cast.h>
22#include <xrpl/basics/scope.h>
23#include <xrpl/beast/utility/instrumentation.h>
24#include <xrpl/ledger/AmendmentTable.h>
25#include <xrpl/ledger/OrderBookDB.h>
26#include <xrpl/protocol/BuildInfo.h>
27#include <xrpl/protocol/HashPrefix.h>
28#include <xrpl/protocol/digest.h>
29#include <xrpl/rdb/RelationalDatabase.h>
30#include <xrpl/resource/Fees.h>
31#include <xrpl/server/LoadFeeTrack.h>
32#include <xrpl/server/NetworkOPs.h>
61 bool const ret = [&]() {
63 if (candidateLedger >= currentLedger)
67 if (currentLedger - candidateLedger <= ledgerHistory)
72 return minimumOnline.
has_value() && candidateLedger >= *minimumOnline;
75 JLOG(j.
trace()) <<
"Missing ledger " << candidateLedger << (ret ?
" should" :
" should NOT")
87 , mLedgerHistory(collector, app)
88 , standalone_(app_.config().standalone())
89 , fetch_depth_(app_.getSHAMapStore().clampFetchDepth(app_.config().FETCH_DEPTH))
90 , ledger_history_(app_.config().LEDGER_HISTORY)
95 std::chrono::seconds{45},
97 app_.journal(
"TaggedCache"))
119 if (validLedger && !
areCompatible(*validLedger, view, s, reason))
140 using namespace std::chrono_literals;
150 ret = (ret > 0s) ? ret : 0s;
164 using namespace std::chrono_literals;
175 ret = (ret > 0s) ? ret : 0s;
189 using namespace std::chrono_literals;
193 reason =
"No recently-published ledger";
198 if (!validClose || !pubClose)
200 reason =
"No published ledger";
203 if (validClose > (pubClose + 90))
205 reason =
"Published ledger lags validated ledger";
221 times.
reserve(validations.size());
222 for (
auto const& val : validations)
225 if (!validations.empty())
226 consensusHash = validations.front()->getConsensusHash();
235 auto const t0 = times[(times.
size() - 1) / 2];
236 auto const t1 = times[times.
size() / 2];
237 signTime = t0 + (t1 - t0) / 2;
241 signTime = l->header().closeTime;
249 "xrpl::LedgerMaster::setValidLedger : valid ledger sequence");
262 "activated: server blocked.";
279 "reached majority. Upgrade before "
281 <<
" to prevent your server from "
282 "becoming amendment blocked.";
312 XRPL_ASSERT(ledger,
"xrpl::LedgerMaster::canBeCurrent : non-null input");
318 if (validLedger && (ledger->header().seq < validLedger->header().seq))
320 JLOG(
m_journal.
trace()) <<
"Candidate for current ledger has low seq "
321 << ledger->header().seq <<
" < " << validLedger->header().seq;
331 auto ledgerClose = ledger->header().parentCloseTime;
333 using namespace std::chrono_literals;
334 if ((validLedger || (ledger->header().seq > 10)) &&
335 ((
std::max(closeTime, ledgerClose) -
std::min(closeTime, ledgerClose)) > 5min))
337 JLOG(
m_journal.
warn()) <<
"Candidate for current ledger has close time "
338 <<
to_string(ledgerClose) <<
" at network time "
339 <<
to_string(closeTime) <<
" seq " << ledger->header().seq;
350 LedgerIndex maxSeq = validLedger->header().seq + 10;
352 if (closeTime > validLedger->header().parentCloseTime)
353 maxSeq += std::chrono::duration_cast<std::chrono::seconds>(
354 closeTime - validLedger->header().parentCloseTime)
358 if (ledger->header().seq > maxSeq)
360 JLOG(
m_journal.
warn()) <<
"Candidate for current ledger has high seq "
361 << ledger->header().seq <<
" > " << maxSeq;
365 JLOG(
m_journal.
trace()) <<
"Acceptable seq range: " << validLedger->header().seq
366 <<
" <= " << ledger->header().seq <<
" <= " << maxSeq;
375 XRPL_ASSERT(lastClosed,
"xrpl::LedgerMaster::switchLCL : non-null input");
376 if (!lastClosed->isImmutable())
379 if (lastClosed->open())
380 LogicError(
"The new last closed ledger is open!");
407 bool validated = ledger->header().validated;
483 XRPL_ASSERT(hash->isNonZero(),
"xrpl::LedgerMaster::isValidated : nonzero hash");
525 minVal = 1 + *maybeMin;
542 if (!pendingSaves.empty() && ((minVal != 0) || (maxVal != 0)))
547 while (pendingSaves.count(maxVal) > 0)
549 while (pendingSaves.count(minVal) > 0)
553 for (
auto v : pendingSaves)
555 if ((v.first >= minVal) && (v.first <= maxVal))
557 if (v.first > ((minVal + maxVal) / 2))
558 maxVal = v.first - 1;
560 minVal = v.first + 1;
590 uint256 prevHash = ledger->header().parentHash;
609 auto it(ledgerHashes.
find(seq));
611 if (it == ledgerHashes.
end())
623 it = ledgerHashes.
find(seq);
625 if (it == ledgerHashes.
end())
628 if (!nodeStore.fetchNodeObject(
629 ledgerHashes.
begin()->second.ledgerHash, ledgerHashes.
begin()->first))
633 <<
"SQL DB ledger sequence " << seq <<
" mismatches node store";
638 if (it->second.ledgerHash != prevHash)
641 prevHash = it->second.parentHash;
663 if (!haveHash || haveHash->isZero())
665 JLOG(
m_journal.
error()) <<
"No hash for fetch pack. Missing Index " << missing;
675 for (
auto const& peer : peerList)
677 if (peer->hasRange(missing, missing + 1))
679 int score = peer->getScore(
true);
680 if (!target || (score > maxScore))
691 protocol::TMGetObjectByHash tmBH;
692 tmBH.set_query(
true);
693 tmBH.set_type(protocol::TMGetObjectByHash::otFETCH_PACK);
694 tmBH.set_ledgerhash(haveHash->begin(), 32);
697 target->send(packet);
698 JLOG(
m_journal.
trace()) <<
"Requested fetch pack for " << missing;
721 <<
"fixMismatch encounters partial ledger. Exception: " << ex.
what();
731 if (otherLedger && (otherLedger->header().hash == *hash))
736 JLOG(
m_journal.
warn()) <<
"Match at " << lSeq <<
", " << invalidate
737 <<
" prior ledgers invalidated";
752 JLOG(
m_journal.
warn()) <<
"All " << invalidate <<
" prior ledgers invalidated";
764 <<
" accepted :" << ledger->header().hash;
766 ledger->stateMap().getHash().isNonZero(),
767 "xrpl::LedgerMaster::setFullLedger : nonzero ledger state hash");
769 ledger->setValidated();
779 if (prevHash.
isNonZero() && prevHash != ledger->header().parentHash)
801 if (ledger->header().seq != 0 &&
haveLedger(ledger->header().seq - 1))
806 if (!prevLedger || (prevLedger->header().hash != ledger->header().parentHash))
808 JLOG(
m_journal.
warn()) <<
"Acquired ledger invalidates previous ledger: "
809 << (prevLedger ?
"hashMismatch" :
"missingLedger");
838 valCount = validations.size();
903 auto const tvc = validations.size();
906 JLOG(
m_journal.
trace()) <<
"Only " << tvc <<
" validations for " << ledger->header().hash;
910 JLOG(
m_journal.
info()) <<
"Advancing accepted ledger to " << ledger->header().seq
911 <<
" with >= " << minVal <<
" validations";
913 ledger->setValidated();
927 fees.reserve(fees.size() + fees2.size());
937 s <<
"Received fees from validations: (" << fees.size() <<
") ";
938 for (
auto const fee1 : fees)
944 fee = fees[fees.size() / 2];
955 if (ledger->seq() % 256 == 0)
966 bool needPrint =
false;
974 ledger->header().parentHash, ledger->header().seq - 1);
977 for (
auto const& v : vals)
979 if (v->isFieldPresent(sfServerVersion))
981 auto version = v->getFieldU64(sfServerVersion);
990 if (higherVersionCount > 0 && rippledCount > 0)
995 needPrint = unlSize > 0 &&
1013 auto const upgradeMsg =
1014 "Check for upgrade: "
1015 "A majority of trusted validators are "
1016 "running a newer version.";
1042 JLOG(stream) <<
"Consensus built old ledger: " << ledger->header().seq
1053 JLOG(stream) <<
"Consensus ledger fully validated";
1066 valSeq() : valCount_(0), ledgerSeq_(0)
1077 if (ledgerSeq_ == 0)
1087 for (
auto const& v : validations)
1089 valSeq& vs = count[v->getLedgerHash()];
1090 vs.mergeValidation(v->getFieldU32(sfLedgerSequence));
1095 auto maxLedger = ledger->header().hash;
1099 for (
auto& v : count)
1100 if (v.second.valCount_ > neededValidations)
1103 if (v.second.ledgerSeq_ == 0)
1106 v.second.ledgerSeq_ = l->header().seq;
1109 if (v.second.ledgerSeq_ > maxSeq)
1111 maxSeq = v.second.ledgerSeq_;
1112 maxLedger = v.first;
1119 JLOG(stream) <<
"Consensus triggered check of ledger";
1131 if (l && l->header().seq >= index)
1154 JLOG(
m_journal.
trace()) <<
"No valid journal, nothing to publish.";
1179 JLOG(
m_journal.
trace()) <<
"No valid journal, nothing to publish.";
1194 JLOG(
m_journal.
trace()) <<
"Trying to fetch/publish valid ledger " << seq;
1208 else if (hash->isZero())
1212 <<
"Ledger: " << valSeq <<
" does not have hash for " << seq;
1214 "xrpl::LedgerMaster::findNewLedgersToPublish : ledger "
1232 if (ledger && (ledger->header().seq == pubSeq))
1234 ledger->setValidated();
1244 JLOG(
m_journal.
error()) <<
"Exception while trying to find ledgers to publish: "
1257 auto finishLedger = valLedger;
1258 while (startLedger->seq() + 1 < finishLedger->seq())
1260 if (
auto const parent =
1264 finishLedger = parent;
1268 auto numberLedgers = finishLedger->seq() - startLedger->seq() + 1;
1270 <<
"Publish LedgerReplays " << numberLedgers
1271 <<
" ledgers, from seq=" << startLedger->header().seq <<
", "
1272 << startLedger->header().hash <<
" to seq=" << finishLedger->header().seq
1273 <<
", " << finishLedger->header().hash;
1299 "xrpl::LedgerMaster::tryAdvance : has valid ledger");
1327 JLOG(
m_journal.
debug()) <<
"Need network ledger for updating paths";
1362 lastLedger->header().closeTime;
1365 JLOG(
m_journal.
debug()) <<
"Published ledger too old for updating paths";
1378 if (!pathRequests.requestsPending())
1382 JLOG(
m_journal.
debug()) <<
"No path requests found. Nothing to do for updating "
1389 pathRequests.updateAll(lastLedger);
1392 if (!pathRequests.requestsPending())
1394 JLOG(
m_journal.
debug()) <<
"No path requests left. No need for further updating "
1404 if (lastLedger->open())
1408 lastLedger->header().parentHash,
1409 lastLedger->header().seq - 1,
1416 lastLedger->header().hash,
1417 lastLedger->header().seq,
1459 JLOG(
m_journal.
debug()) <<
"newPFWork: Creating job. path find threads: "
1498 return ledger->rules();
1530 if (nodeObject && (nodeObject->getData().size() >= 120))
1532 SerialIter it(nodeObject->getData().data(), nodeObject->getData().size());
1550 if (
hash.isNonZero())
1573 if (!referenceLedger || (referenceLedger->header().seq < index))
1588 XRPL_ASSERT(refHash,
"xrpl::LedgerMaster::walkHashBySeq : found ledger");
1614 "xrpl::LedgerMaster::walkHashBySeq : has complete "
1630 if (
valid->header().seq == index)
1651 if (ret && (ret->header().seq == index))
1665 if (ret && (ret->header().hash ==
hash))
1727 XRPL_ASSERT(
hash->isNonZero(),
"xrpl::LedgerMaster::fetchForHistory : found ledger");
1737 JLOG(
m_journal.
trace()) <<
"fetchForHistory want fetch pack " << missing;
1742 JLOG(
m_journal.
trace()) <<
"fetchForHistory no fetch pack for " << missing;
1745 JLOG(
m_journal.
debug()) <<
"fetchForHistory found failed acquire";
1749 auto seq = ledger->header().seq;
1750 XRPL_ASSERT(seq == missing,
"xrpl::LedgerMaster::fetchForHistory : sequence match");
1759 if (fillInProgress == 0 &&
1789 "xrpl::LedgerMaster::fetchForHistory : "
1790 "prefetched ledger");
1803 JLOG(
m_journal.
fatal()) <<
"Can't find ledger following prevMissing " << missing;
1821 bool progress =
false;
1824 if (pubLedgers.empty())
1844 JLOG(
m_journal.
trace()) <<
"tryAdvance discovered missing " << *missing;
1863 JLOG(
m_journal.
debug()) <<
"tryAdvance found last valid changed";
1877 <<
"tryAdvance found " << pubLedgers.size() <<
" ledgers to publish";
1878 for (
auto const& ledger : pubLedgers)
1882 JLOG(
m_journal.
debug()) <<
"tryAdvance publishing seq " << ledger->header().seq;
1895 progress =
newPFWork(
"PthFindNewLed", sl);
1963 protocol::TMGetObjectByHash* into,
1965 bool withLeaves =
true)
1967 XRPL_ASSERT(cnt,
"xrpl::populateFetchPack : nonzero count input");
1972 if (!withLeaves && n.
isLeaf())
1980 protocol::TMIndexedObject* obj = into->add_objects();
1981 obj->set_ledgerseq(seq);
1982 obj->set_hash(
hash.data(),
hash.size());
1996 using namespace std::chrono_literals;
2009 auto peer = wPeer.
lock();
2018 JLOG(
m_journal.
info()) <<
"Peer requests fetch pack for ledger we don't have: " << have;
2025 JLOG(
m_journal.
warn()) <<
"Peer requests fetch pack from open ledger: " << have;
2032 JLOG(
m_journal.
debug()) <<
"Peer requests fetch pack that is too early";
2041 JLOG(
m_journal.
info()) <<
"Peer requests fetch pack for ledger whose predecessor we "
2042 <<
"don't have: " << have;
2051 protocol::TMGetObjectByHash reply;
2052 reply.set_query(
false);
2054 if (request->has_seq())
2055 reply.set_seq(request->seq());
2057 reply.set_ledgerhash(request->ledgerhash());
2058 reply.set_type(protocol::TMGetObjectByHash::otFETCH_PACK);
2077 addRaw(want->header(), hdr);
2080 protocol::TMIndexedObject* obj = reply.add_objects();
2081 obj->set_hash(want->header().hash.data(), want->header().hash.size());
2083 obj->set_ledgerseq(lSeq);
2090 if (want->header().txHash.isNonZero())
2093 if (reply.objects().size() >= 512)
2096 have = std::move(want);
2102 JLOG(
m_journal.
info()) <<
"Built fetch pack with " << reply.objects().size() <<
" nodes ("
2103 << msg->getBufferSize() <<
" bytes)";
2109 JLOG(
m_journal.
warn()) <<
"Exception building fetch pack. Exception: " << ex.
what();
2135 if (!lgr || lgr->txs.empty())
2138 for (
auto it = lgr->txs.begin(); it != lgr->txs.end(); ++it)
2139 if (it->first && it->second && it->second->isFieldPresent(sfTransactionIndex) &&
2140 it->second->getFieldU32(sfTransactionIndex) == txnIndex)
2141 return it->first->getTransactionID();
T back_inserter(T... args)
Provide a light-weight way to check active() before string formatting.
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
typename Clock::time_point time_point
virtual bool hasUnsupportedEnabled() const =0
returns true if one or more amendments on the network have been enabled that this server does not sup...
void doValidatedLedger(std::shared_ptr< ReadView const > const &lastValidatedLedger)
Called when a new fully-validated ledger is accepted.
virtual std::optional< NetClock::time_point > firstUnsupportedExpected() const =0
virtual Config & config()=0
virtual LedgerIndex getMaxDisallowedLedger()=0
Ensure that a newly-started validator does not sign proposals older than the last ledger it persisted...
Holds transactions which were deferred to the next pass of consensus.
void insert(std::shared_ptr< STTx const > const &txn)
std::shared_ptr< STTx const > popAcctTransaction(std::shared_ptr< STTx const > const &tx)
std::unordered_set< uint256, beast::uhash<> > features
virtual bool isFailure(uint256 const &h)=0
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
int getJobCount(JobType t) const
Jobs waiting at this priority.
void validatedLedger(std::shared_ptr< Ledger const > const &, std::optional< uint256 > const &consensusHash)
Report that we have validated a particular ledger.
bool insert(std::shared_ptr< Ledger const > const &ledger, bool validated)
Track a ledger.
float getCacheHitRate()
Get the ledgers_by_hash cache hit rate.
LedgerHash getLedgerHash(LedgerIndex ledgerIndex)
Get a ledger's hash given its sequence number.
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const &ledgerHash)
Repair a hash to index mapping.
std::shared_ptr< Ledger const > getLedgerByHash(LedgerHash const &ledgerHash)
Retrieve a ledger given its hash.
void sweep()
Remove stale cache entries.
void builtLedger(std::shared_ptr< Ledger const > const &, uint256 const &consensusHash, Json::Value)
Report that we have locally built a particular ledger.
std::shared_ptr< Ledger const > getLedgerBySeq(LedgerIndex ledgerIndex)
Get a ledger given its sequence number.
void clearLedgerCachePrior(LedgerIndex seq)
void set(std::shared_ptr< Ledger const > ledger)
std::shared_ptr< Ledger const > get()
std::optional< LedgerIndex > minSqlSeq()
std::atomic< LedgerIndex > mValidLedgerSeq
void consensusBuilt(std::shared_ptr< Ledger const > const &ledger, uint256 const &consensusHash, Json::Value consensus)
Report that the consensus process built a particular ledger.
bool haveLedger(std::uint32_t seq)
TaggedCache< uint256, Blob > fetch_packs_
std::size_t getNeededValidations()
Determines how many validations are needed to fully validate a ledger.
bool isCompatible(ReadView const &, beast::Journal::Stream, char const *reason)
std::shared_ptr< STTx const > popAcctTransaction(std::shared_ptr< STTx const > const &tx)
Get the next transaction held for a particular account if any.
void setValidLedger(std::shared_ptr< Ledger const > const &l)
void switchLCL(std::shared_ptr< Ledger const > const &lastClosed)
std::recursive_mutex & peekMutex()
std::chrono::seconds getValidatedLedgerAge()
TimeKeeper::time_point upgradeWarningPrevTime_
LedgerIndex getCurrentLedgerIndex()
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const &ledgerHash)
bool getValidatedRange(std::uint32_t &minVal, std::uint32_t &maxVal)
void applyHeldTransactions()
Apply held transactions to the open ledger This is normally called as we close the ledger.
bool storeLedger(std::shared_ptr< Ledger const > ledger)
void gotFetchPack(bool progress, std::uint32_t seq)
void tryFill(std::shared_ptr< Ledger const > ledger)
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
void setPubLedger(std::shared_ptr< Ledger const > const &l)
bool newPFWork(char const *name, std::unique_lock< std::recursive_mutex > &)
A thread needs to be dispatched to handle pathfinding work of some kind.
void setFullLedger(std::shared_ptr< Ledger const > const &ledger, bool isSynchronous, bool isCurrent)
void clearPriorLedgers(LedgerIndex seq)
LedgerIndex const max_ledger_difference_
CanonicalTXSet mHeldTransactions
std::uint32_t const ledger_fetch_size_
void setBuildingLedger(LedgerIndex index)
std::pair< uint256, LedgerIndex > mLastValidLedger
bool isCaughtUp(std::string &reason)
std::size_t getFetchPackCacheSize() const
std::optional< Blob > getFetchPack(uint256 const &hash) override
Retrieves partial ledger data of the corresponding hash from peers.
std::vector< std::shared_ptr< Ledger const > > findNewLedgersToPublish(std::unique_lock< std::recursive_mutex > &)
std::atomic< std::uint32_t > mPubLedgerClose
std::optional< NetClock::time_point > getCloseTimeByHash(LedgerHash const &ledgerHash, LedgerIndex ledgerIndex)
std::uint32_t const fetch_depth_
std::atomic< LedgerIndex > mPubLedgerSeq
void clearLedger(std::uint32_t seq)
void clearLedgerCachePrior(LedgerIndex seq)
std::atomic_flag mGotFetchPackThread
uint256 getHashBySeq(std::uint32_t index)
Get a ledger's hash by sequence number using the cache.
std::shared_ptr< Ledger const > getClosedLedger()
void setLedgerRangePresent(std::uint32_t minV, std::uint32_t maxV)
std::optional< NetClock::time_point > getCloseTimeBySeq(LedgerIndex ledgerIndex)
std::string getCompleteLedgers()
std::shared_ptr< Ledger const > getValidatedLedger()
void fetchForHistory(std::uint32_t missing, bool &progress, InboundLedger::Reason reason, std::unique_lock< std::recursive_mutex > &)
std::uint32_t const ledger_history_
bool isValidated(ReadView const &ledger)
void fixMismatch(ReadView const &ledger)
void makeFetchPack(std::weak_ptr< Peer > const &wPeer, std::shared_ptr< protocol::TMGetObjectByHash > const &request, uint256 haveLedgerHash, UptimeClock::time_point uptime)
LedgerIndex getValidLedgerIndex()
std::shared_ptr< Ledger const > mPathLedger
std::shared_ptr< ReadView const > getPublishedLedger()
Rules getValidatedRules()
std::shared_ptr< Ledger const > mHistLedger
std::optional< LedgerHash > walkHashBySeq(std::uint32_t index, InboundLedger::Reason reason)
Walk to a ledger's hash using the skip list.
LedgerHistory mLedgerHistory
LedgerMaster(Application &app, Stopwatch &stopwatch, beast::insight::Collector::ptr const &collector, beast::Journal journal)
std::atomic< std::uint32_t > mValidLedgerSign
std::chrono::seconds getPublishedLedgerAge()
std::optional< uint256 > txnIdFromIndex(uint32_t ledgerSeq, uint32_t txnIndex)
bool canBeCurrent(std::shared_ptr< Ledger const > const &ledger)
Check the sequence number and parent close time of a ledger against our clock and last validated ledg...
void addFetchPack(uint256 const &hash, std::shared_ptr< Blob > data)
bool getFullValidatedRange(std::uint32_t &minVal, std::uint32_t &maxVal)
std::optional< LedgerHash > getLedgerHashForHistory(LedgerIndex index, InboundLedger::Reason reason)
RangeSet< std::uint32_t > mCompleteLedgers
LedgerHolder mValidLedger
void checkAccept(std::shared_ptr< Ledger const > const &ledger)
LedgerHolder mClosedLedger
void doAdvance(std::unique_lock< std::recursive_mutex > &)
void addHeldTransaction(std::shared_ptr< Transaction > const &trans)
std::shared_ptr< ReadView const > getCurrentLedger()
void takeReplay(std::unique_ptr< LedgerReplay > replay)
std::unique_ptr< LedgerReplay > replayData
std::unique_ptr< LedgerReplay > releaseReplay()
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
std::uint32_t getEarliestFetch()
std::recursive_mutex m_mutex
std::shared_ptr< Ledger const > mPubLedger
void failedSave(std::uint32_t seq, uint256 const &hash)
std::atomic< LedgerIndex > mBuildingLedgerSeq
std::recursive_mutex mCompleteLock
void replay(InboundLedger::Reason r, uint256 const &finishLedgerHash, std::uint32_t totalNumLedgers)
Replay a range of ledgers.
void setRemoteFee(std::uint32_t f)
bool isLoadedLocal() const
std::uint32_t getLoadBase() const
virtual void setAmendmentBlocked()=0
virtual bool isBlocked()=0
virtual void processTransactionSet(CanonicalTXSet const &set)=0
Process a set of transactions synchronously, and ensuring that they are processed in one batch.
virtual void updateLocalTx(ReadView const &newValidLedger)=0
virtual void clearAmendmentWarned()=0
virtual bool isAmendmentWarned()=0
virtual void pubLedger(std::shared_ptr< ReadView const > const &lpAccepted)=0
virtual bool isNeedNetworkLedger()=0
virtual void clearNeedNetworkLedger()=0
virtual void setAmendmentWarned()=0
Persistency layer for NodeObject.
std::uint32_t earliestLedgerSeq() const noexcept
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t ledgerSeq=0, FetchType fetchType=FetchType::synchronous, bool duplicate=false)
Fetch a node object.
virtual std::int32_t getWriteLoad() const =0
Retrieve the estimated number of pending write operations.
std::shared_ptr< OpenView const > current() const
Returns a view to the current open ledger.
virtual void setup(std::shared_ptr< ReadView const > const &ledger)=0
Initialize or update the order book database with a new ledger.
virtual void checkTracking(std::uint32_t index)=0
Calls the checkTracking function on each peer.
virtual PeerSequence getActivePeers() const =0
Returns a sequence representing the current list of peers.
bool requestsPending() const
std::map< LedgerIndex, bool > getSnapshot() const
Get a snapshot of the pending saves.
virtual LedgerHeader const & header() const =0
Returns information about the ledger.
virtual bool open() const =0
Returns true if this reflects an open ledger.
virtual uint256 getHashByIndex(LedgerIndex ledgerIndex)=0
getHashByIndex Returns the hash of the ledger with the given sequence.
virtual std::optional< LedgerIndex > getMinLedgerSeq()=0
getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers table.
virtual std::optional< LedgerHashPair > getHashesByIndex(LedgerIndex ledgerIndex)=0
getHashesByIndex Returns the hashes of the ledger and its parent as specified by the ledgerIndex.
Rules controlling protocol behavior.
uint256 const & as_uint256() const
virtual std::optional< LedgerIndex > minimumOnline() const =0
The minimum ledger to try and maintain in our database.
virtual void onLedgerClosed(std::shared_ptr< Ledger const > const &ledger)=0
Called by LedgerMaster every time a ledger validates.
SHAMapHash const & getHash() const
Return the hash of this node.
virtual void serializeWithPrefix(Serializer &) const =0
Serialize the node in a format appropriate for hashing.
virtual bool isLeaf() const =0
Determines if this is a leaf node.
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
void visitDifferences(SHAMap const *have, std::function< bool(SHAMapTreeNode const &)> const &) const
Visit every node in this SHAMap that is not present in the specified SHAMap.
void const * getDataPtr() const
virtual JobQueue & getJobQueue()=0
virtual RelationalDatabase & getRelationalDatabase()=0
virtual AmendmentTable & getAmendmentTable()=0
virtual PendingSaves & pendingSaves()=0
virtual ValidatorList & validators()=0
virtual NetworkOPs & getOPs()=0
virtual SHAMapStore & getSHAMapStore()=0
virtual Overlay & overlay()=0
virtual NodeStore::Database & getNodeStore()=0
virtual PathRequests & getPathRequests()=0
virtual RCLValidations & getValidations()=0
virtual LoadFeeTrack & getFeeTrack()=0
virtual OpenLedger & openLedger()=0
virtual InboundLedgers & getInboundLedgers()=0
virtual LedgerMaster & getLedgerMaster()=0
virtual bool isStopping() const =0
virtual LedgerReplayer & getLedgerReplayer()=0
virtual TimeKeeper & timeKeeper()=0
virtual OrderBookDB & getOrderBookDB()=0
virtual beast::Journal journal(std::string const &name)=0
time_point now() const override
Returns the current time, using the server's clock.
time_point closeTime() const
Returns the predicted close time, in network time.
std::vector< WrappedValidationType > getTrustedForLedger(ID const &ledgerID, Seq const &seq)
Get trusted full validations for a specific ledger.
std::vector< WrappedValidationType > currentTrusted()
Get the currently trusted full validations.
std::vector< std::uint32_t > fees(ID const &ledgerID, std::uint32_t baseFee)
Returns fees reported by trusted full validators in the given ledger.
QuorumKeys getQuorumKeys() const
Get the quorum and all of the trusted keys.
std::size_t quorum() const
Get quorum value for current trusted key set.
std::vector< std::shared_ptr< STValidation > > negativeUNLFilter(std::vector< std::shared_ptr< STValidation > > &&validations) const
Remove validations that are from validators on the negative UNL.
Automatically unlocks and re-locks a unique_lock object.
bool isNewerVersion(std::uint64_t version)
Check if the version is newer than the local node's rippled software version.
bool isRippledVersion(std::uint64_t version)
Check if the encoded software version is a rippled software version.
Charge const feeMalformedRequest
Schedule of fees charged for imposing load on the server.
Charge const feeRequestNoReply
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
bool isCurrent(ValidationParms const &p, NetClock::time_point now, NetClock::time_point signTime, NetClock::time_point seenTime)
Whether a validation is still current.
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
std::optional< T > prevMissing(RangeSet< T > const &rs, T t, T minVal=0)
Find the largest value not in the set that is less than a given value.
static constexpr std::chrono::minutes MAX_LEDGER_AGE_ACQUIRE
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
std::string to_string(base_uint< Bits, Tag > const &a)
constexpr std::size_t calculatePercent(std::size_t count, std::size_t total)
Calculate one number divided by another number in percentage.
static void populateFetchPack(SHAMap const &want, SHAMap const *have, std::uint32_t cnt, protocol::TMGetObjectByHash *into, std::uint32_t seq, bool withLeaves=true)
Populate a fetch pack with data from the map the recipient wants.
bool pendSaveValidated(Application &app, std::shared_ptr< Ledger const > const &ledger, bool isSynchronous, bool isCurrent)
Save, or arrange to save, a fully-validated ledger Returns false on error.
bool areCompatible(ReadView const &validLedger, ReadView const &testLedger, beast::Journal::Stream &s, char const *reason)
Return false if the test ledger is provably incompatible with the valid ledger, that is,...
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
void addRaw(LedgerHeader const &, Serializer &, bool includeHash=false)
static constexpr int MAX_LEDGER_GAP
@ ledgerMaster
ledger master data for signing
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
static constexpr int MAX_WRITE_LOAD_ACQUIRE
static bool shouldAcquire(std::uint32_t const currentLedger, std::uint32_t const ledgerHistory, std::optional< LedgerIndex > const minimumOnline, std::uint32_t const candidateLedger, beast::Journal j)
T test_and_set(T... args)
T time_since_epoch(T... args)