20 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/ledger/OpenLedger.h>
22 #include <ripple/app/ledger/OrderBookDB.h>
23 #include <ripple/app/ledger/PendingSaves.h>
24 #include <ripple/app/tx/apply.h>
25 #include <ripple/app/main/Application.h>
26 #include <ripple/app/misc/AmendmentTable.h>
27 #include <ripple/app/misc/HashRouter.h>
28 #include <ripple/app/misc/LoadFeeTrack.h>
29 #include <ripple/app/misc/NetworkOPs.h>
30 #include <ripple/app/misc/SHAMapStore.h>
31 #include <ripple/app/misc/Transaction.h>
32 #include <ripple/app/misc/TxQ.h>
33 #include <ripple/app/consensus/RCLValidations.h>
34 #include <ripple/app/misc/ValidatorList.h>
35 #include <ripple/app/paths/PathRequests.h>
36 #include <ripple/basics/contract.h>
37 #include <ripple/basics/safe_cast.h>
38 #include <ripple/basics/Log.h>
39 #include <ripple/basics/TaggedCache.h>
40 #include <ripple/basics/UptimeClock.h>
41 #include <ripple/core/DatabaseCon.h>
42 #include <ripple/core/TimeKeeper.h>
43 #include <ripple/nodestore/DatabaseShard.h>
44 #include <ripple/overlay/Overlay.h>
45 #include <ripple/overlay/Peer.h>
46 #include <ripple/protocol/digest.h>
47 #include <ripple/protocol/HashPrefix.h>
48 #include <ripple/resource/Fees.h>
96 template <
class MutexType>
114 assert(lock_.owns_lock());
118 ScopedUnlock (ScopedUnlock
const&) =
delete;
119 ScopedUnlock& operator= (ScopedUnlock
const&) =
delete;
128 ~ScopedUnlock() noexcept(false)
147 static boost::optional<LedgerIndex>
150 boost::optional<LedgerIndex> seq;
152 *db <<
"SELECT MIN(LedgerSeq) FROM Ledgers", soci::into(seq);
162 boost::optional<LedgerIndex> minSeq,
170 if (candidateLedger >= currentLedger)
174 if (currentLedger - candidateLedger <= ledgerHistory)
191 << (ret ?
" should" :
" should NOT")
201 , m_journal (journal)
202 , mLedgerHistory (collector, app)
203 , mLedgerCleaner (detail::make_LedgerCleaner (
204 app, *this, app_.journal(
"LedgerCleaner")))
205 , standalone_ (app_.config().standalone())
206 , fetch_depth_ (app_.getSHAMapStore ().clampFetchDepth (
207 app_.config().FETCH_DEPTH))
208 , ledger_history_ (app_.config().LEDGER_HISTORY)
210 , fetch_packs_ (
"FetchPack", 65536,
std::chrono::seconds {45},
stopwatch,
211 app_.journal(
"TaggedCache"))
259 using namespace std::chrono_literals;
269 ret = (ret > 0s) ? ret : 0s;
278 using namespace std::chrono_literals;
288 ret = (ret > 0s) ? ret : 0s;
297 using namespace std::chrono_literals;
300 reason =
"No recently-published ledger";
305 if (!validClose || !pubClose)
307 reason =
"No published ledger";
310 if (validClose > (pubClose + 90))
312 reason =
"Published ledger lags validated ledger";
324 boost::optional<uint256> consensusHash;
330 for(
auto const& val: vals)
334 consensusHash = vals.front()->getConsensusHash();
343 auto const t0 = times[(times.
size() - 1) / 2];
344 auto const t1 = times[times.
size() / 2];
345 signTime = t0 + (t1 - t0)/2;
349 signTime = l->info().closeTime;
370 "activated: server blocked.";
384 if (
auto const first =
388 "reached majority. Upgrade before "
390 <<
" to prevent your server from "
391 "becoming amendment blocked.";
430 (ledger->info().seq < validLedger->info().seq))
432 JLOG (
m_journal.
trace()) <<
"Candidate for current ledger has low seq "
433 << ledger->info().seq <<
" < " << validLedger->info().seq;
443 auto ledgerClose = ledger->info().parentCloseTime;
445 using namespace std::chrono_literals;
446 if ((validLedger || (ledger->info().seq > 10)) &&
450 JLOG (
m_journal.
warn()) <<
"Candidate for current ledger has close time "
451 <<
to_string(ledgerClose) <<
" at network time "
452 <<
to_string(closeTime) <<
" seq " << ledger->info().seq;
465 if (closeTime > validLedger->info().parentCloseTime)
466 maxSeq += std::chrono::duration_cast<std::chrono::seconds>(
467 closeTime - validLedger->info().parentCloseTime).count() / 2;
469 if (ledger->info().seq > maxSeq)
471 JLOG (
m_journal.
warn()) <<
"Candidate for current ledger has high seq "
472 << ledger->info().seq <<
" > " << maxSeq;
477 validLedger->info().seq <<
" <= " <<
478 ledger->info().seq <<
" <= " << maxSeq;
488 if(! lastClosed->isImmutable())
491 if (lastClosed->open())
492 LogicError (
"The new last closed ledger is open!");
541 app_, view, it.second, flags, j);
603 boost::optional<std::uint32_t> maybeMin;
609 if (maybeMin == boost::none)
612 minVal = 1 + *maybeMin;
627 auto const pendingSaves =
630 if (!pendingSaves.empty() && ((minVal != 0) || (maxVal != 0)))
635 while (pendingSaves.count(maxVal) > 0)
637 while (pendingSaves.count(minVal) > 0)
641 for(
auto v : pendingSaves)
643 if ((v.first >= minVal) && (v.first <= maxVal))
645 if (v.first > ((minVal + maxVal) / 2))
646 maxVal = v.first - 1;
648 minVal = v.first + 1;
680 uint256 prevHash = ledger->info().parentHash;
699 auto it (ledgerHashes.
find (seq));
701 if (it == ledgerHashes.
end ())
713 : (seq - 499), seq,
app_);
714 it = ledgerHashes.
find (seq);
716 if (it == ledgerHashes.
end ())
719 if (!nodeStore.fetch(ledgerHashes.
begin()->second.first,
720 ledgerHashes.
begin()->first))
724 "SQL DB ledger sequence " << seq <<
725 " mismatches node store";
730 if (it->second.first != prevHash)
733 prevHash = it->second.second;
754 if (!haveHash || haveHash->isZero())
760 if (missing < shardStore->lastLedgerSeq(shardIndex))
763 <<
"No hash for fetch pack. "
764 <<
"Missing ledger sequence " << missing
765 <<
" while acquiring shard " << shardIndex;
771 "No hash for fetch pack. Missing Index " << missing;
782 for (
auto const& peer : peerList)
784 if (peer->hasRange (missing, missing + 1))
786 int score = peer->getScore (
true);
787 if (! target || (score > maxScore))
798 protocol::TMGetObjectByHash tmBH;
799 tmBH.set_query (
true);
800 tmBH.set_type (protocol::TMGetObjectByHash::otFETCH_PACK);
801 tmBH.set_ledgerhash (haveHash->begin(), 32);
802 auto packet = std::make_shared<Message> (
803 tmBH, protocol::mtGET_OBJECTS);
805 target->send (packet);
806 JLOG(
m_journal.
trace()) <<
"Requested fetch pack for " << missing;
816 boost::optional<uint256> hash;
829 "fixMismatch encounters partial ledger";
839 if (otherLedger && (otherLedger->info().hash == *hash))
845 <<
"Match at " << lSeq
846 <<
", " << invalidate
847 <<
" prior ledgers invalidated";
863 "All " << invalidate <<
" prior ledgers invalidated";
874 "Ledger " << ledger->info().seq <<
875 " accepted :" << ledger->info().hash;
876 assert (ledger->stateMap().getHash ().isNonZero ());
878 ledger->setValidated();
888 if (prevHash.
isNonZero () && prevHash != ledger->info().parentHash)
911 if (ledger->info().seq != 0 &&
haveLedger (ledger->info().seq - 1))
917 (prevLedger->info().hash != ledger->info().parentHash))
920 <<
"Acquired ledger invalidates previous ledger: "
921 << (prevLedger ?
"hashMismatch" :
"missingLedger");
1021 " validations for " << ledger->info().hash;
1026 <<
"Advancing accepted ledger to " << ledger->info().seq
1027 <<
" with >= " << minVal <<
" validations";
1029 ledger->setValidated();
1043 ledger->info(). parentHash, base);
1044 fees.reserve (fees.size() + fees2.size());
1051 fee = fees[fees.size() / 2];
1084 <<
"Consensus built old ledger: "
1096 <<
"Consensus ledger fully validated";
1111 valSeq () : valCount_ (0), ledgerSeq_ (0) { ; }
1118 if (ledgerSeq_ == 0)
1128 for (
auto const& v : val)
1130 valSeq& vs = count[v->getLedgerHash()];
1136 auto maxLedger = ledger->info().hash;
1140 for (
auto& v : count)
1141 if (v.second.valCount_ > neededValidations)
1144 if (v.second.ledgerSeq_ == 0)
1147 v.second.ledgerSeq_ = l->info().seq;
1150 if (v.second.ledgerSeq_ > maxSeq)
1152 maxSeq = v.second.ledgerSeq_;
1153 maxLedger = v.first;
1161 <<
"Consensus triggered check of ledger";
1187 boost::optional<LedgerHash>
1192 boost::optional<LedgerHash> ret;
1196 if (l && l->info().seq >= index)
1220 "No valid journal, nothing to publish.";
1242 return { valLedger };
1248 "No valid journal, nothing to publish.";
1258 ScopedUnlock sul{sl};
1264 <<
"Trying to fetch/publish valid ledger " << seq;
1278 else if (hash->isZero())
1281 <<
"Ledger: " << valSeq
1282 <<
" does not have hash for " << seq;
1296 if (ledger && (ledger->info().seq == pubSeq))
1298 ledger->setValidated();
1305 "ready to publish " << ret.
size() <<
" ledgers.";
1310 "Exception while trying to find ledgers to publish.";
1334 boost::optional<LedgerHash>
1339 assert(desiredSeq < knownGoodLedger->info().seq);
1347 assert(seq < desiredSeq);
1408 - lastLedger->info().closeTime;
1412 <<
"Published ledger too old for updating paths";
1427 <<
"During pathfinding: " << mn.
what();
1428 if (lastLedger->open())
1432 lastLedger->info().parentHash,
1433 lastLedger->info().seq - 1,
1440 lastLedger->info().hash,
1441 lastLedger->info().seq,
1485 [
this] (
Job& j) { updatePaths(j); }))
1516 return ledger->rules();
1537 boost::optional <NetClock::time_point>
1542 hash, ledgerIndex) : boost::none;
1545 boost::optional <NetClock::time_point>
1551 (node->getData().size() >= 120))
1553 SerialIter it (node->getData().data(), node->getData().size());
1577 boost::optional<LedgerHash>
1580 boost::optional<LedgerHash> ledgerHash;
1588 boost::optional<LedgerHash>
1593 if (!referenceLedger || (referenceLedger->info().seq < index))
1633 assert (ledgerHash);
1648 if (valid->info().seq == index)
1669 if (ret && (ret->info().seq == index))
1683 if (ret && (ret->info().hash == hash))
1760 ScopedUnlock sul{sl};
1763 assert(hash->isNonZero());
1770 *hash, missing, reason);
1776 <<
"fetchForHistory want fetch pack " << missing;
1782 <<
"fetchForHistory no fetch pack for " << missing;
1786 <<
"fetchForHistory found failed acquire";
1790 auto seq = ledger->info().seq;
1791 assert(seq == missing);
1793 "fetchForHistory acquired " << seq;
1801 if (!ledger->stateMap().family().isShardBacked())
1813 if (fillInProgress == 0 &&
1822 [
this, ledger](
Job& j) {
tryFill(j, ledger); });
1839 fetchSz = missing >= fetchSz ?
1848 assert(h->isNonZero());
1861 JLOG(
m_journal.
fatal()) <<
"Can't find ledger following prevMissing "
1880 bool progress =
false;
1883 if (pubLedgers.empty())
1893 boost::optional<std::uint32_t> missing;
1903 "tryAdvance discovered missing " << *missing;
1911 "advanceThread should acquire";
1914 missing = boost::none;
1931 "tryAdvance found last valid changed";
1941 "tryAdvance not fetching history";
1947 "tryAdvance found " << pubLedgers.size() <<
1948 " ledgers to publish";
1949 for(
auto ledger : pubLedgers)
1952 ScopedUnlock sul{sl};
1954 "tryAdvance publishing seq " << ledger->info().seq;
1961 ScopedUnlock sul{sl};
1967 progress =
newPFWork (
"pf:newLedger", sl);
1982 boost::optional<Blob>
2020 using namespace std::chrono_literals;
2034 auto peer = wPeer.
lock ();
2044 <<
"Peer requests fetch pack for ledger we don't have: "
2053 <<
"Peer requests fetch pack from open ledger: "
2062 <<
"Peer requests fetch pack that is too early";
2072 <<
"Peer requests fetch pack for ledger whose predecessor we "
2079 auto fpAppender = [](
2080 protocol::TMGetObjectByHash* reply,
2085 protocol::TMIndexedObject& newObj = * (reply->add_objects ());
2086 newObj.set_ledgerseq (ledgerSeq);
2087 newObj.set_hash (hash.as_uint256().begin (), 256 / 8);
2088 newObj.set_data (&blob[0], blob.size ());
2093 protocol::TMGetObjectByHash reply;
2094 reply.set_query (
false);
2096 if (request->has_seq ())
2097 reply.set_seq (request->seq ());
2099 reply.set_ledgerhash (request->ledgerhash ());
2100 reply.set_type (protocol::TMGetObjectByHash::otFETCH_PACK);
2115 protocol::TMIndexedObject& newObj = *reply.add_objects ();
2117 wantLedger->info().hash.data(), 256 / 8);
2120 addRaw(wantLedger->info(), s);
2122 newObj.set_ledgerseq (lSeq);
2124 wantLedger->stateMap().getFetchPack
2126 std::bind (fpAppender, &reply, lSeq, std::placeholders::_1,
2127 std::placeholders::_2));
2129 if (wantLedger->info().txHash.isNonZero ())
2130 wantLedger->txMap().getFetchPack (
2132 std::bind (fpAppender, &reply, lSeq, std::placeholders::_1,
2133 std::placeholders::_2));
2135 if (reply.objects ().size () >= 512)
2142 while (wantLedger &&
2146 <<
"Built fetch pack with " << reply.objects ().size () <<
" nodes";
2147 auto msg = std::make_shared<Message> (reply, protocol::mtGET_OBJECTS);
virtual void pubLedger(std::shared_ptr< ReadView const > const &lpAccepted)=0
virtual LedgerInfo const & info() const =0
Returns information about the ledger.
bool getValidatedRange(std::uint32_t &minVal, std::uint32_t &maxVal)
std::shared_ptr< Ledger const > mPubLedger
const Charge feeInvalidRequest
Schedule of fees charged for imposing load on the server.
LedgerHolder mClosedLedger
virtual OrderBookDB & getOrderBookDB()=0
@ 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)
virtual std::int32_t getWriteLoad() const =0
Retrieve the estimated number of pending write operations.
std::shared_ptr< ReadView const > getPublishedLedger()
std::uint32_t LedgerIndex
A ledger index.
TaggedCache< uint256, Blob > fetch_packs_
std::shared_ptr< OpenView const > current() const
Returns a view to the current open ledger.
Persistency layer for NodeObject.
void makeFetchPack(std::weak_ptr< Peer > const &wPeer, std::shared_ptr< protocol::TMGetObjectByHash > const &request, uint256 haveLedgerHash, UptimeClock::time_point uptime)
void clearLedgerCachePrior(LedgerIndex seq)
Stream trace() const
Severity stream access functions.
std::atomic< LedgerIndex > mBuildingLedgerSeq
virtual std::uint32_t seqToShardIndex(std::uint32_t seq) const =0
Calculates the shard index for a given ledger sequence.
std::pair< TER, bool > apply(Application &app, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
std::vector< std::shared_ptr< STTx const > > pruneHeldTransactions(AccountID const &account, std::uint32_t const seq)
Get all the transactions held for a particular account.
LedgerHistory mLedgerHistory
boost::optional< LedgerHash > getLedgerHashForHistory(LedgerIndex index, InboundLedger::Reason reason)
T test_and_set(T... args)
CanonicalTXSet mHeldTransactions
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const &ledgerHash)
Repair a hash to index mapping.
std::vector< std::uint32_t > fees(ID const &ledgerID, std::uint32_t baseFee)
Returns fees reported by trusted full validators in the given ledger.
Subclasses can be called to write to a stream and have children.
void set(std::shared_ptr< Ledger const > ledger)
LedgerIndex getValidLedgerIndex()
virtual AmendmentTable & getAmendmentTable()=0
Writable ledger view that accumulates state and tx changes.
virtual bool isShutdown()=0
std::shared_ptr< Ledger const > mHistLedger
std::chrono::seconds getPublishedLedgerAge()
virtual PeerSequence getActivePeers()=0
Returns a sequence representing the current list of peers.
T back_inserter(T... args)
std::unique_ptr< LedgerReplay > releaseReplay()
virtual void onLedgerClosed(std::shared_ptr< Ledger const > const &ledger)=0
Called by LedgerMaster every time a ledger validates.
Rules getValidatedRules()
void doValidatedLedger(std::shared_ptr< ReadView const > const &lastValidatedLedger)
Called when a new fully-validated ledger is accepted.
std::recursive_mutex mCompleteLock
void tune(int size, std::chrono::seconds age)
Set the history cache's parameters.
void applyHeldTransactions()
Apply held transactions to the open ledger This is normally called as we close the ledger.
void switchLCL(std::shared_ptr< Ledger const > const &lastClosed)
bool newPFWork(const char *name, std::unique_lock< std::recursive_mutex > &)
A thread needs to be dispatched to handle pathfinding work of some kind.
virtual void setAmendmentBlocked()=0
virtual NodeStore::DatabaseShard * getShardStore()=0
virtual bool isAmendmentWarned()=0
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
void addRaw(LedgerInfo const &info, Serializer &s)
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
std::uint32_t getLoadBase() const
boost::optional< NetClock::time_point > getCloseTimeByHash(LedgerHash const &ledgerHash, LedgerIndex ledgerIndex)
std::string to_string(ListDisposition disposition)
virtual TimeKeeper & timeKeeper()=0
std::uint32_t getEarliestFetch()
virtual bool isAmendmentBlocked()=0
virtual OpenLedger & openLedger()=0
void sweep()
Remove stale cache entries.
const Charge feeRequestNoReply
LedgerHash getLedgerHash(LedgerIndex ledgerIndex)
Get a ledger's hash given its sequence number.
void setFullLedger(std::shared_ptr< Ledger const > const &ledger, bool isSynchronous, bool isCurrent)
void tune(int size, std::chrono::seconds age)
virtual NetworkOPs & getOPs()=0
void fixMismatch(ReadView const &ledger)
virtual LedgerIndex getLastRotated()=0
Maximum ledger that has been deleted, or will be deleted if currently in the act of online deletion.
const std::uint32_t fetch_depth_
virtual InboundLedgers & getInboundLedgers()=0
void builtLedger(std::shared_ptr< Ledger const > const &, uint256 const &consensusHash, Json::Value)
Report that we have locally built a particular ledger.
virtual LoadFeeTrack & getFeeTrack()=0
std::string getCompleteLedgers()
const std::uint32_t ledger_fetch_size_
CancelCallback getCancelCallback() const
uint256 getHashByIndex(std::uint32_t ledgerIndex, Application &app)
int getJobCount(JobType t) const
Jobs waiting at this priority.
std::recursive_mutex & peekMutex()
virtual bool hasUnsupportedEnabled()=0
returns true if one or more amendments on the network have been enabled that this server does not sup...
std::atomic_flag mGotFetchPackThread
bool isLoadedLocal() const
T time_since_epoch(T... args)
RangeSet< std::uint32_t > mCompleteLedgers
beast::PropertyStream::Source & getPropertySource()
LedgerMaster(Application &app, Stopwatch &stopwatch, Stoppable &parent, beast::insight::Collector::ptr const &collector, beast::Journal journal)
Provides an interface for starting and stopping.
virtual bool isNeedNetworkLedger()=0
bool insert(std::shared_ptr< Ledger const > ledger, bool validated)
Track a ledger.
LockedSociSession checkoutDb()
std::unique_ptr< LedgerReplay > replayData
void gotFetchPack(bool progress, std::uint32_t seq)
void fetchForHistory(std::uint32_t missing, bool &progress, InboundLedger::Reason reason, std::unique_lock< std::recursive_mutex > &)
void failedSave(std::uint32_t seq, uint256 const &hash)
virtual LedgerMaster & getLedgerMaster()=0
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
bool shouldCancel() const
Returns true if the running job should make a best-effort cancel.
virtual void setAmendmentWarned()=0
virtual PendingSaves & pendingSaves()=0
std::shared_ptr< Ledger const > getLedgerByHash(LedgerHash const &ledgerHash)
Retrieve a ledger given its hash.
const void * getDataPtr() const
static constexpr int MAX_LEDGER_GAP
boost::optional< Blob > getFetchPack(uint256 const &hash) override
Retrieves partial ledger data of the coresponding hash from peers.
virtual std::shared_ptr< NodeObject > fetch(uint256 const &hash, std::uint32_t seq)=0
Fetch an object.
bool getFullValidatedRange(std::uint32_t &minVal, std::uint32_t &maxVal)
virtual void updateLocalTx(ReadView const &newValidLedger)=0
virtual Config & config()=0
bool fixIndex(LedgerIndex ledgerIndex, LedgerHash const &ledgerHash)
bool isCurrent(ValidationParms const &p, NetClock::time_point now, NetClock::time_point signTime, NetClock::time_point seenTime)
Whether a validation is still current.
boost::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.
std::size_t numTrustedForLedger(ID const &ledgerID)
Count the number of trusted full validations for the given ledger.
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...
virtual JobQueue & getJobQueue()=0
bool haveLedger(std::uint32_t seq)
std::shared_ptr< Ledger const > getValidatedLedger()
Provide a light-weight way to check active() before string formatting.
const SF_U32 sfLedgerSequence(access, STI_UINT32, 6, "LedgerSequence")
bool isCompatible(ReadView const &, beast::Journal::Stream, char const *reason)
virtual void checkSanity(std::uint32_t index)=0
Calls the checkSanity function on each peer.
void setup(std::shared_ptr< ReadView const > const &ledger)
void validatedLedger(std::shared_ptr< Ledger const > const &, boost::optional< uint256 > const &consensusHash)
Report that we have validated a particular ledger.
std::shared_ptr< Ledger const > getLedgerBySeq(std::uint32_t index)
virtual time_point closeTime() const =0
Returns the close time, in network time.
A generic endpoint for log messages.
virtual RCLValidations & getValidations()=0
virtual DatabaseCon & getLedgerDB()=0
std::unique_ptr< detail::LedgerCleaner > mLedgerCleaner
std::uint32_t earliestLedgerSeq() const
void addHeldTransaction(std::shared_ptr< Transaction > const &trans)
void setValidLedger(std::shared_ptr< Ledger const > const &l)
virtual void clearNeedNetworkLedger()=0
virtual std::uint32_t firstLedgerSeq(std::uint32_t shardIndex) const =0
Calculates the first ledger sequence for a given shard index.
std::shared_ptr< Ledger const > getLedgerBySeq(LedgerIndex ledgerIndex)
Get a ledger given its sequence number.
ClosedInterval< T > range(T low, T high)
Create a closed range interval.
virtual PathRequests & getPathRequests()=0
std::shared_ptr< Ledger const > get()
void insert(std::shared_ptr< STTx const > const &txn)
std::shared_ptr< ReadView const > getCurrentLedger()
std::map< LedgerIndex, bool > getSnapshot() const
Get a snapshot of the pending saves.
std::vector< WrappedValidationType > getTrustedForLedger(ID const &ledgerID)
Get trusted full validations for a specific ledger.
std::size_t getNeededValidations()
Determines how many validations are needed to fully validate a ledger.
bool areCompatible(ReadView const &validLedger, ReadView const &testLedger, beast::Journal::Stream &s, const char *reason)
Return false if the test ledger is provably incompatible with the valid ledger, that is,...
boost::optional< LedgerHash > getLedgerHash(std::uint32_t desiredSeq, std::shared_ptr< ReadView const > const &knownGoodLedger)
void checkAccept(std::shared_ptr< Ledger const > const &ledger)
virtual ValidatorList & validators()=0
const LedgerIndex max_ledger_difference_
std::size_t getFetchPackCacheSize() const
void doLedgerCleaner(Json::Value const ¶meters)
boost::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
std::shared_ptr< Ledger const > mPathLedger
std::chrono::seconds getValidatedLedgerAge()
static bool shouldAcquire(std::uint32_t const currentLedger, std::uint32_t const ledgerHistory, boost::optional< LedgerIndex > minSeq, std::uint32_t const lastRotated, std::uint32_t const candidateLedger, beast::Journal j)
std::shared_ptr< Ledger const > getClosedLedger()
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::unordered_set< uint256, beast::uhash<> > features
virtual bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger)=0
Copies a ledger stored in a different database to this one.
std::atomic< std::uint32_t > mPubLedgerClose
virtual NodeStore::Database & getNodeStore()=0
virtual beast::Journal journal(std::string const &name)=0
const std::uint32_t ledger_history_
std::atomic< LedgerIndex > mPubLedgerSeq
float getCacheHitRate()
Get the ledgers_by_hash cache hit rate.
LedgerIndex getBuildingLedger()
void clearLedger(std::uint32_t seq)
virtual void clearAmendmentWarned()=0
boost::optional< NetClock::time_point > getCloseTimeBySeq(LedgerIndex ledgerIndex)
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
sha512_half_hasher::result_type sha512Half(Args const &... args)
Returns the SHA512-Half of a series of objects.
std::vector< std::shared_ptr< STTx const > > prune(AccountID const &account, std::uint32_t const seq)
static constexpr std::chrono::minutes MAX_LEDGER_AGE_ACQUIRE
std::atomic< LedgerIndex > mValidLedgerSeq
LedgerIndex getCurrentLedgerIndex()
virtual Overlay & overlay()=0
void takeReplay(std::unique_ptr< LedgerReplay > replay)
std::pair< uint256, LedgerIndex > mLastValidLedger
Rules controlling protocol behavior.
void clearLedgerCachePrior(LedgerIndex seq)
std::shared_ptr< Ledger const > mShardLedger
void updatePaths(Job &job)
static boost::optional< LedgerIndex > minSqlSeq(Application &app)
bool getHashesByIndex(std::uint32_t ledgerIndex, uint256 &ledgerHash, uint256 &parentHash, Application &app)
virtual boost::optional< NetClock::time_point > firstUnsupportedExpected()=0
bool storeLedger(std::shared_ptr< Ledger const > ledger)
virtual SHAMapStore & getSHAMapStore()=0
void setLedgerRangePresent(std::uint32_t minV, std::uint32_t maxV)
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
void consensusBuilt(std::shared_ptr< Ledger const > const &ledger, uint256 const &consensusHash, Json::Value consensus)
Report that the consensus process built a particular ledger.
void updateAll(std::shared_ptr< ReadView const > const &ledger, Job::CancelCallback shouldCancel)
Update all of the contained PathRequest instances.
LedgerHolder mValidLedger
void setRemoteFee(std::uint32_t f)
uint256 getHashBySeq(std::uint32_t index)
Get a ledger's hash by sequence number using the cache.
std::vector< std::shared_ptr< Ledger const > > findNewLedgersToPublish(std::unique_lock< std::recursive_mutex > &)
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 isCaughtUp(std::string &reason)
std::atomic< std::uint32_t > mValidLedgerSign
void setBuildingLedger(LedgerIndex index)
boost::optional< LedgerHash > walkHashBySeq(std::uint32_t index)
Walk to a ledger's hash using the skip list.
void doAdvance(std::unique_lock< std::recursive_mutex > &)
void clearPriorLedgers(LedgerIndex seq)
void setPubLedger(std::shared_ptr< Ledger const > const &l)
bool modify(modify_type const &f)
Modify the open ledger.
virtual bool isFailure(uint256 const &h)=0
void tryFill(Job &job, std::shared_ptr< Ledger const > ledger)
void addFetchPack(uint256 const &hash, std::shared_ptr< Blob > &data)
void reset(LedgerHash const &salt)
static constexpr int MAX_WRITE_LOAD_ACQUIRE
std::size_t quorum() const
Get quorum value for current trusted key set.
virtual LedgerIndex getMaxDisallowedLedger()=0
Ensure that a newly-started validator does not sign proposals older than the last ledger it persisted...
std::recursive_mutex m_mutex
std::vector< WrappedValidationType > currentTrusted()
Get the currently trusted full validations.
bool isStopping() const
Returns true if the stoppable should stop.