20 #include <ripple/app/ledger/BuildLedger.h>
21 #include <ripple/app/ledger/InboundLedger.h>
22 #include <ripple/app/ledger/LedgerReplay.h>
23 #include <ripple/app/ledger/LedgerReplayer.h>
24 #include <ripple/app/ledger/impl/LedgerDeltaAcquire.h>
25 #include <ripple/app/main/Application.h>
26 #include <ripple/core/JobQueue.h>
27 #include <ripple/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_;
203 assert(parent->info().hash ==
replayTemp_->info().parentHash);
218 << parent->info().hash;
219 Throw<std::runtime_error>(
"Cannot replay ledger");
229 << (reason ?
" for a new reason" :
"");
233 bool firstTime =
true;
237 reasons.push_back(*reason);
244 for (
auto reason : reasons)
249 app.getLedgerMaster().storeLedger(ledger);
258 app.getLedgerMaster().tryAdvance();
271 for (
auto& cb : toCall)
std::vector< OnDeltaDataCB > dataReadyCallbacks_
virtual Family & getNodeFamily()=0
void notify(ScopedLockType &sl)
Call the OnDeltaDataCB callbacks.
constexpr std::uint32_t SUB_TASK_MAX_TIMEOUTS
const std::uint32_t ledgerSeq_
std::map< std::uint32_t, std::shared_ptr< STTx const > > orderedTxns_
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.
constexpr auto SUB_TASK_FALLBACK_TIMEOUT
~LedgerDeltaAcquire() override
Stream trace() const
Severity stream access functions.
void setTimer(ScopedLockType &)
Schedule a call to queueJob() after mTimerInterval.
std::unique_ptr< PeerSet > peerSet_
void init(int numPeers)
Start the LedgerDeltaAcquire task.
std::shared_ptr< Ledger const > getLedgerByHash(uint256 const &hash)
std::shared_ptr< Ledger const > fullLedger_
InboundLedgers & inboundLedgers_
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
This class is an "active" object.
std::recursive_mutex mtx_
constexpr static std::size_t size()
constexpr std::uint32_t MAX_QUEUED_TASKS
std::shared_ptr< Ledger const > replayTemp_
T shared_from_this(T... args)
virtual LedgerMaster & getLedgerMaster()=0
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
std::set< InboundLedger::Reason > reasons_
virtual Config & config()=0
virtual JobQueue & getJobQueue()=0
void trigger(std::size_t limit, ScopedLockType &sl)
Trigger another round.
void addDataCallback(InboundLedger::Reason reason, OnDeltaDataCB &&cb)
Add a reason and a callback to the LedgerDeltaAcquire subtask.
Manages the lifetime of inbound ledgers.
std::weak_ptr< TimeoutCounter > pmDowncast() override
Return a weak pointer to this.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const uint256 hash_
The hash of the object (in practice, always a ledger) we are trying to fetch.
std::uint32_t noFeaturePeerCount
std::shared_ptr< Ledger > buildLedger(std::shared_ptr< Ledger const > const &parent, NetClock::time_point closeTime, const bool closeTimeCorrect, NetClock::duration closeResolution, Application &app, CanonicalTXSet &txns, std::set< TxID > &failedTxs, beast::Journal j)
Build a new ledger by applying consensus transactions.
std::shared_ptr< Ledger const > tryBuild(std::shared_ptr< Ledger const > const &parent)
Try to build the ledger if not already.
constexpr auto MAX_NO_FEATURE_PEER_COUNT
Information about the notional ledger backing the view.
std::chrono::milliseconds timerInterval_
The minimum time to wait between calls to execute().
LedgerDeltaAcquire(Application &app, InboundLedgers &inboundLedgers, uint256 const &ledgerHash, std::uint32_t ledgerSeq, std::unique_ptr< PeerSet > peerSet)
Constructor.
void onTimer(bool progress, ScopedLockType &peerSetLock) override
Hook called from invokeOnTimer().
void onLedgerBuilt(ScopedLockType &sl, std::optional< InboundLedger::Reason > reason={})
Process a newly built ledger, such as store it.