rippled
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
xrpl::LedgerReplayTask Class Referencefinal

#include <LedgerReplayTask.h>

Inheritance diagram for xrpl::LedgerReplayTask:
Inheritance graph
[legend]
Collaboration diagram for xrpl::LedgerReplayTask:
Collaboration graph
[legend]

Classes

class  TaskParameter
 

Public Member Functions

 LedgerReplayTask (Application &app, InboundLedgers &inboundLedgers, LedgerReplayer &replayer, std::shared_ptr< SkipListAcquire > &skipListAcquirer, TaskParameter &&parameter)
 Constructor.
 
 ~LedgerReplayTask ()
 
void init ()
 Start the task.
 
void addDelta (std::shared_ptr< LedgerDeltaAcquire > const &delta)
 add a new LedgerDeltaAcquire subtask
 
TaskParameter const & getTaskParameter () const
 
bool finished () const
 return if the task is finished
 
virtual void cancel ()
 Cancel the task by marking it as failed if the task is not done.
 
shared_from_this (T... args)
 
weak_from_this (T... args)
 

Protected Types

using ScopedLockType = std::unique_lock< std::recursive_mutex >
 

Protected Member Functions

void setTimer (ScopedLockType &)
 Schedule a call to queueJob() after mTimerInterval.
 
void queueJob (ScopedLockType &)
 Queue a job to call invokeOnTimer().
 
bool isDone () const
 

Protected Attributes

Applicationapp_
 
beast::Journal journal_
 
std::recursive_mutex mtx_
 
uint256 const hash_
 The hash of the object (in practice, always a ledger) we are trying to fetch.
 
int timeouts_
 
bool complete_
 
bool failed_
 
bool progress_
 Whether forward progress has been made.
 
std::chrono::milliseconds timerInterval_
 The minimum time to wait between calls to execute().
 
QueueJobParameter queueJobParameter_
 

Private Member Functions

void onTimer (bool progress, ScopedLockType &sl) override
 Hook called from invokeOnTimer().
 
std::weak_ptr< TimeoutCounterpmDowncast () override
 Return a weak pointer to this.
 
void updateSkipList (uint256 const &hash, std::uint32_t seq, std::vector< uint256 > const &sList)
 Update this task (by a SkipListAcquire subtask) when skip list is ready.
 
void deltaReady (uint256 const &deltaHash)
 Notify this task (by a LedgerDeltaAcquire subtask) that a delta is ready.
 
void trigger (ScopedLockType &sl)
 Trigger another round.
 
void tryAdvance (ScopedLockType &sl)
 Try to build more ledgers.
 
void invokeOnTimer ()
 Calls onTimer() if in the right state.
 

Static Private Member Functions

static auto & getCounter () noexcept
 

Private Attributes

InboundLedgersinboundLedgers_
 
LedgerReplayerreplayer_
 
TaskParameter parameter_
 
uint32_t maxTimeouts_
 
std::shared_ptr< SkipListAcquireskipListAcquirer_
 
std::shared_ptr< Ledger const > parent_ = {}
 
uint32_t deltaToBuild_ = 0
 
std::vector< std::shared_ptr< LedgerDeltaAcquire > > deltas_
 
boost::asio::basic_waitable_timer< std::chrono::steady_clocktimer_
 

Friends

class test::LedgerReplayClient
 

Detailed Description

Definition at line 20 of file LedgerReplayTask.h.

Member Typedef Documentation

◆ ScopedLockType

Definition at line 64 of file TimeoutCounter.h.

Constructor & Destructor Documentation

◆ LedgerReplayTask()

xrpl::LedgerReplayTask::LedgerReplayTask ( Application app,
InboundLedgers inboundLedgers,
LedgerReplayer replayer,
std::shared_ptr< SkipListAcquire > &  skipListAcquirer,
TaskParameter &&  parameter 
)

Constructor.

Parameters
appApplication reference
inboundLedgersInboundLedgers reference
replayerLedgerReplayer reference
skipListAcquirershared_ptr of SkipListAcquire subtask, to make sure it will not be destroyed.
parameterparameter of the task

Definition at line 69 of file LedgerReplayTask.cpp.

◆ ~LedgerReplayTask()

xrpl::LedgerReplayTask::~LedgerReplayTask ( )

Definition at line 95 of file LedgerReplayTask.cpp.

Member Function Documentation

◆ init()

void xrpl::LedgerReplayTask::init ( )

Start the task.

Definition at line 101 of file LedgerReplayTask.cpp.

◆ addDelta()

void xrpl::LedgerReplayTask::addDelta ( std::shared_ptr< LedgerDeltaAcquire > const &  delta)

add a new LedgerDeltaAcquire subtask

Parameters
deltathe new LedgerDeltaAcquire subtask
Note
the LedgerDeltaAcquire subtasks must be added in order

Definition at line 259 of file LedgerReplayTask.cpp.

◆ getTaskParameter()

TaskParameter const & xrpl::LedgerReplayTask::getTaskParameter ( ) const

Definition at line 103 of file LedgerReplayTask.h.

◆ finished()

bool xrpl::LedgerReplayTask::finished ( ) const

return if the task is finished

Definition at line 289 of file LedgerReplayTask.cpp.

◆ onTimer()

void xrpl::LedgerReplayTask::onTimer ( bool  progress,
ScopedLockType  
)
overrideprivatevirtual

Hook called from invokeOnTimer().

Implements xrpl::TimeoutCounter.

Definition at line 237 of file LedgerReplayTask.cpp.

◆ pmDowncast()

std::weak_ptr< TimeoutCounter > xrpl::LedgerReplayTask::pmDowncast ( )
overrideprivatevirtual

Return a weak pointer to this.

Implements xrpl::TimeoutCounter.

Definition at line 253 of file LedgerReplayTask.cpp.

◆ updateSkipList()

void xrpl::LedgerReplayTask::updateSkipList ( uint256 const &  hash,
std::uint32_t  seq,
std::vector< uint256 > const &  sList 
)
private

Update this task (by a SkipListAcquire subtask) when skip list is ready.

Parameters
hashhash of the ledger that has the skip list
seqsequence number of the ledger that has the skip list
sListskip list

Definition at line 213 of file LedgerReplayTask.cpp.

◆ deltaReady()

void xrpl::LedgerReplayTask::deltaReady ( uint256 const &  deltaHash)
private

Notify this task (by a LedgerDeltaAcquire subtask) that a delta is ready.

Parameters
deltaHashledger hash of the delta

Definition at line 159 of file LedgerReplayTask.cpp.

◆ trigger()

void xrpl::LedgerReplayTask::trigger ( ScopedLockType sl)
private

Trigger another round.

Parameters
sllock. this function must be called with the lock

Definition at line 131 of file LedgerReplayTask.cpp.

◆ tryAdvance()

void xrpl::LedgerReplayTask::tryAdvance ( ScopedLockType sl)
private

Try to build more ledgers.

Parameters
sllock. this function must be called with the lock

Definition at line 169 of file LedgerReplayTask.cpp.

◆ cancel()

void xrpl::TimeoutCounter::cancel ( )
virtualinherited

Cancel the task by marking it as failed if the task is not done.

Note
this function does not attempt to cancel the scheduled timer or to remove the queued job if any. When the timer expires or the queued job starts, however, the code will see that the task is done and returns immediately, if it can lock the weak pointer of the task.

Definition at line 100 of file TimeoutCounter.cpp.

◆ setTimer()

void xrpl::TimeoutCounter::setTimer ( ScopedLockType sl)
protectedinherited

Schedule a call to queueJob() after mTimerInterval.

Definition at line 32 of file TimeoutCounter.cpp.

◆ queueJob()

void xrpl::TimeoutCounter::queueJob ( ScopedLockType sl)
protectedinherited

Queue a job to call invokeOnTimer().

Definition at line 51 of file TimeoutCounter.cpp.

◆ isDone()

bool xrpl::TimeoutCounter::isDone ( ) const
protectedinherited

Definition at line 99 of file TimeoutCounter.h.

◆ invokeOnTimer()

void xrpl::TimeoutCounter::invokeOnTimer ( )
privateinherited

Calls onTimer() if in the right state.

Only called by queueJob().

Definition at line 75 of file TimeoutCounter.cpp.

◆ getCounter()

static auto & xrpl::CountedObject< LedgerReplayTask >::getCounter ( )
staticprivatenoexceptinherited

Definition at line 110 of file CountedObject.h.

Friends And Related Symbol Documentation

◆ test::LedgerReplayClient

friend class test::LedgerReplayClient
friend

Definition at line 161 of file LedgerReplayTask.h.

Member Data Documentation

◆ inboundLedgers_

InboundLedgers& xrpl::LedgerReplayTask::inboundLedgers_
private

Definition at line 152 of file LedgerReplayTask.h.

◆ replayer_

LedgerReplayer& xrpl::LedgerReplayTask::replayer_
private

Definition at line 153 of file LedgerReplayTask.h.

◆ parameter_

TaskParameter xrpl::LedgerReplayTask::parameter_
private

Definition at line 154 of file LedgerReplayTask.h.

◆ maxTimeouts_

uint32_t xrpl::LedgerReplayTask::maxTimeouts_
private

Definition at line 155 of file LedgerReplayTask.h.

◆ skipListAcquirer_

std::shared_ptr<SkipListAcquire> xrpl::LedgerReplayTask::skipListAcquirer_
private

Definition at line 156 of file LedgerReplayTask.h.

◆ parent_

std::shared_ptr<Ledger const> xrpl::LedgerReplayTask::parent_ = {}
private

Definition at line 157 of file LedgerReplayTask.h.

◆ deltaToBuild_

uint32_t xrpl::LedgerReplayTask::deltaToBuild_ = 0
private

Definition at line 158 of file LedgerReplayTask.h.

◆ deltas_

std::vector<std::shared_ptr<LedgerDeltaAcquire> > xrpl::LedgerReplayTask::deltas_
private

Definition at line 159 of file LedgerReplayTask.h.

◆ app_

Application& xrpl::TimeoutCounter::app_
protectedinherited

Definition at line 106 of file TimeoutCounter.h.

◆ journal_

beast::Journal xrpl::TimeoutCounter::journal_
protectedinherited

Definition at line 107 of file TimeoutCounter.h.

◆ mtx_

std::recursive_mutex xrpl::TimeoutCounter::mtx_
mutableprotectedinherited

Definition at line 108 of file TimeoutCounter.h.

◆ hash_

uint256 const xrpl::TimeoutCounter::hash_
protectedinherited

The hash of the object (in practice, always a ledger) we are trying to fetch.

Definition at line 112 of file TimeoutCounter.h.

◆ timeouts_

int xrpl::TimeoutCounter::timeouts_
protectedinherited

Definition at line 113 of file TimeoutCounter.h.

◆ complete_

bool xrpl::TimeoutCounter::complete_
protectedinherited

Definition at line 114 of file TimeoutCounter.h.

◆ failed_

bool xrpl::TimeoutCounter::failed_
protectedinherited

Definition at line 115 of file TimeoutCounter.h.

◆ progress_

bool xrpl::TimeoutCounter::progress_
protectedinherited

Whether forward progress has been made.

Definition at line 117 of file TimeoutCounter.h.

◆ timerInterval_

std::chrono::milliseconds xrpl::TimeoutCounter::timerInterval_
protectedinherited

The minimum time to wait between calls to execute().

Definition at line 119 of file TimeoutCounter.h.

◆ queueJobParameter_

QueueJobParameter xrpl::TimeoutCounter::queueJobParameter_
protectedinherited

Definition at line 121 of file TimeoutCounter.h.

◆ timer_

boost::asio::basic_waitable_timer<std::chrono::steady_clock> xrpl::TimeoutCounter::timer_
privateinherited

Definition at line 130 of file TimeoutCounter.h.