20#include <xrpld/app/ledger/BuildLedger.h>
21#include <xrpld/app/ledger/InboundLedger.h>
22#include <xrpld/app/ledger/LedgerReplay.h>
23#include <xrpld/app/ledger/LedgerReplayer.h>
24#include <xrpld/app/ledger/detail/LedgerDeltaAcquire.h>
25#include <xrpld/app/main/Application.h>
26#include <xrpld/core/JobQueue.h>
27#include <xrpld/overlay/PeerSet.h>
40 LedgerReplayParameters::SUB_TASK_TIMEOUT,
44 app.journal(
"LedgerReplayDelta"))
45 , inboundLedgers_(inboundLedgers)
46 , ledgerSeq_(ledgerSeq)
47 , peerSet_(std::move(peerSet))
49 JLOG(journal_.trace()) <<
"Create " << hash_ <<
" Seq " << ledgerSeq;
92 <<
"Add a peer " << peer->id() <<
" for " <<
hash_;
93 protocol::TMReplayDeltaRequest request;
95 peerSet_->sendRequest(request, peer);
165 <<
"failed to create a (info only) ledger from verified data " <<
hash_;
186 <<
"task added to a finished LedgerDeltaAcquire " <<
hash_;
204 "ripple::LedgerDeltaAcquire::tryBuild : parent sequence match");
206 parent->info().hash ==
replayTemp_->info().parentHash,
207 "ripple::LedgerDeltaAcquire::tryBuild : parent hash match");
222 << parent->info().hash;
223 Throw<std::runtime_error>(
"Cannot replay ledger");
233 << (reason ?
" for a new reason" :
"");
237 bool firstTime =
true;
241 reasons.push_back(*reason);
248 for (
auto reason : reasons)
253 app.getLedgerMaster().storeLedger(ledger);
262 app.getLedgerMaster().tryAdvance();
269 XRPL_ASSERT(
isDone(),
"ripple::LedgerDeltaAcquire::notify : is done");
275 for (
auto& cb : toCall)
Stream trace() const
Severity stream access functions.
virtual Config & config()=0
virtual JobQueue & getJobQueue()=0
virtual Family & getNodeFamily()=0
virtual LedgerMaster & getLedgerMaster()=0
Manages the lifetime of inbound ledgers.
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.
std::shared_ptr< Ledger const > fullLedger_
void trigger(std::size_t limit, ScopedLockType &sl)
Trigger another round.
std::set< InboundLedger::Reason > reasons_
LedgerDeltaAcquire(Application &app, InboundLedgers &inboundLedgers, uint256 const &ledgerHash, std::uint32_t ledgerSeq, std::unique_ptr< PeerSet > peerSet)
Constructor.
void processData(LedgerInfo const &info, std::map< std::uint32_t, std::shared_ptr< STTx const > > &&orderedTxns)
Process the data extracted from a peer's reply.
std::uint32_t noFeaturePeerCount
std::map< std::uint32_t, std::shared_ptr< STTx const > > orderedTxns_
std::shared_ptr< Ledger const > tryBuild(std::shared_ptr< Ledger const > const &parent)
Try to build the ledger if not already.
std::shared_ptr< Ledger const > replayTemp_
InboundLedgers & inboundLedgers_
std::uint32_t const ledgerSeq_
void init(int numPeers)
Start the LedgerDeltaAcquire task.
std::vector< OnDeltaDataCB > dataReadyCallbacks_
~LedgerDeltaAcquire() override
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
std::unique_ptr< PeerSet > peerSet_
void notify(ScopedLockType &sl)
Call the OnDeltaDataCB callbacks.
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
void addDataCallback(InboundLedger::Reason reason, OnDeltaDataCB &&cb)
Add a reason and a callback to the LedgerDeltaAcquire subtask.
void onLedgerBuilt(ScopedLockType &sl, std::optional< InboundLedger::Reason > reason={})
Process a newly built ledger, such as store it.
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
This class is an "active" object.
void setTimer(ScopedLockType &)
Schedule a call to queueJob() after mTimerInterval.
std::chrono::milliseconds timerInterval_
The minimum time to wait between calls to execute().
uint256 const hash_
The hash of the object (in practice, always a ledger) we are trying to fetch.
std::recursive_mutex mtx_
static constexpr std::size_t size()
auto constexpr SUB_TASK_FALLBACK_TIMEOUT
std::uint32_t constexpr MAX_QUEUED_TASKS
std::uint32_t constexpr SUB_TASK_MAX_TIMEOUTS
auto constexpr MAX_NO_FEATURE_PEER_COUNT
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::shared_ptr< Ledger > buildLedger(std::shared_ptr< Ledger const > const &parent, NetClock::time_point closeTime, bool const closeTimeCorrect, NetClock::duration closeResolution, Application &app, CanonicalTXSet &txns, std::set< TxID > &failedTxs, beast::Journal j)
Build a new ledger by applying consensus transactions.
T shared_from_this(T... args)