|
xrpld
|
An acquisition that exposes the entry points its bases keep protected, so a case can reach them through this subclass alone. More...


Public Types | |
| enum class | Reason { HISTORY , GENERIC , CONSENSUS } |
| using | ClockType = beast::AbstractClock<std::chrono::steady_clock> |
| using | NeededHashT = std::pair<protocol::TMGetObjectByHash::ObjectType, UInt256> |
Public Member Functions | |
| void | startAcquire () |
| Look for the ledger locally, ask the peers being tracked for the rest, and arm the timer, as InboundLedgers::acquire() does. | |
| ScopedLockType | lock () const |
| Hold the acquisition's own lock. | |
| void | triggerAdded () |
| Ask for more nodes, or judge what has been collected, as a fresh acquisition does. | |
| void | markComplete () |
| Record that every part has been fetched. | |
| void | signalDone () |
| Settle the acquisition and signal whatever is waiting on it. | |
| InboundLedger (Application &app, UInt256 const &hash, std::uint32_t seq, Reason reason, ClockType &clock, std::unique_ptr< PeerSet > peerSet, std::chrono::milliseconds retryInterval=kRetryInterval) | |
| void | update (std::uint32_t seq) |
| bool | isComplete () const |
| Returns true if we got all the data. | |
| bool | isFailed () const |
| Returns false if we failed to get the data. | |
| std::shared_ptr< Ledger const > | getLedger () const |
| The acquired ledger. | |
| std::uint32_t | getSeq () const |
| bool | checkLocal () |
| void | init (ScopedLockType &collectionLock) |
| bool | gotData (std::weak_ptr< Peer >, std::shared_ptr< protocol::TMLedgerData > const &) |
| Stash a TMLedgerData received from a peer for later processing Returns 'true' if we need to dispatch. | |
| json::Value | getJson (int) |
| Return a json::ValueType::Object. | |
| void | runData () |
| Process pending TMLedgerData Query the a random sample of the 'best' peers. | |
| void | touch () |
| ClockType::time_point | getLastAction () const |
| virtual void | cancel () |
| Cancel the task by marking it as failed if the task is not done. | |
| T | shared_from_this (T... args) |
| T | weak_from_this (T... args) |
Public Attributes | |
| friend | Object |
Static Public Attributes | |
| static constexpr std::chrono::milliseconds | kRetryInterval {3000} |
| How long to wait between retries, and so how long one timeout takes. | |
Protected Types | |
| enum class | TriggerReason { Added , Reply , Timeout } |
| using | ScopedLockType = std::unique_lock<std::recursive_mutex> |
Protected Member Functions | |
| void | trigger (std::shared_ptr< Peer > const &peer, TriggerReason reason) |
| Ask for more nodes, or judge what has been collected. | |
| void | done () |
| Settle the acquisition and signal whatever is waiting on it. | |
| void | setTimer (ScopedLockType &) |
| Schedule a call to queueJob() after timerInterval_. | |
| void | queueJob (ScopedLockType &) |
| Queue a job to call invokeOnTimer(). | |
| bool | isDone () const |
Protected Attributes | |
| Application & | app_ |
| 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_ {0} |
| bool | complete_ {false} |
| bool | failed_ {false} |
| bool | progress_ {false} |
| 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 | filterNodes (std::vector< std::pair< SHAMapNodeID, UInt256 > > &nodes, TriggerReason reason) |
| std::vector< NeededHashT > | getNeededHashes () |
| void | addPeers () |
| Add more peers to the set, if possible. | |
| void | tryDB (node_store::Database &srcDB) |
| void | onTimer (bool progress, ScopedLockType &sl) override |
| Called with a lock by the PeerSet when the timer expires. | |
| std::size_t | getPeerCount () const |
| std::weak_ptr< TimeoutCounter > | pmDowncast () override |
| Return a weak pointer to this. | |
| int | processData (std::shared_ptr< Peer > peer, protocol::TMLedgerData const &data) |
| Process one TMLedgerData Returns the number of useful nodes. | |
| bool | takeHeader (std::string_view data) |
| Build the ledger from a header a peer supplied. | |
| bool | failOnZeroAccountHash () |
| Fail the acquisition when the header's account hash is zero. | |
| void | receiveNode (std::shared_ptr< Peer > const &peer, protocol::TMLedgerData const &packet, SHAMapAddNode &san) |
| Process node data received from a peer Call with a lock. | |
| bool | takeTxRootNode (std::string_view data, SHAMapAddNode &san) |
| Process AS root node received from a peer Call with a lock. | |
| bool | takeAsRootNode (std::string_view data, SHAMapAddNode &san) |
| Process AS root node received from a peer Call with a lock. | |
| std::vector< UInt256 > | neededTxHashes (int max, SHAMapSyncFilter const *filter) const |
| std::vector< UInt256 > | neededStateHashes (int max, SHAMapSyncFilter const *filter) const |
| void | invokeOnTimer () |
| Calls onTimer() if in the right state. | |
Static Private Member Functions | |
| static auto & | getCounter () noexcept |
Private Attributes | |
| ClockType & | clock_ |
| ClockType::time_point | lastAction_ |
| std::shared_ptr< Ledger > | ledger_ |
| bool | haveHeader_ {false} |
| bool | haveState_ {false} |
| bool | haveTransactions_ {false} |
| bool | signaled_ {false} |
| bool | byHash_ {true} |
| std::uint32_t | seq_ |
| Reason const | reason_ |
| std::set< UInt256 > | recentNodes_ |
| SHAMapAddNode | stats_ |
| std::mutex | receivedDataLock_ |
| std::vector< std::pair< std::weak_ptr< Peer >, std::shared_ptr< protocol::TMLedgerData > > > | receivedData_ |
| bool | receiveDispatched_ {false} |
| std::unique_ptr< PeerSet > | peerSet_ |
| boost::asio::basic_waitable_timer< std::chrono::steady_clock > | timer_ |
An acquisition that exposes the entry points its bases keep protected, so a case can reach them through this subclass alone.
Definition at line 34 of file InboundLedger_test.cpp.
|
inherited |
Definition at line 38 of file InboundLedger.h.
|
inherited |
Definition at line 124 of file InboundLedger.h.
|
protectedinherited |
Definition at line 71 of file TimeoutCounter.h.
|
stronginherited |
| Enumerator | |
|---|---|
| HISTORY | |
| GENERIC | |
| CONSENSUS | |
Definition at line 41 of file InboundLedger.h.
|
strongprotectedinherited |
| Enumerator | |
|---|---|
| Added | |
| Reply | |
| Timeout | |
Definition at line 152 of file InboundLedger.h.
| void xrpl::test::TestableInboundLedger::startAcquire | ( | ) |
Look for the ledger locally, ask the peers being tracked for the rest, and arm the timer, as InboundLedgers::acquire() does.
That caller holds its collection lock across init(), which releases it, so this stands in with a lock of its own. The mutex is declared first, so it outlives the lock.
Definition at line 46 of file InboundLedger_test.cpp.
|
nodiscard |
Hold the acquisition's own lock.
The timer chain takes this lock in invokeOnTimer(), so holding it keeps the chain from running until the lock is released. The lock is recursive, so init() can take it again.
Definition at line 61 of file InboundLedger_test.cpp.
| void xrpl::test::TestableInboundLedger::triggerAdded | ( | ) |
Ask for more nodes, or judge what has been collected, as a fresh acquisition does.
Definition at line 71 of file InboundLedger_test.cpp.
| void xrpl::test::TestableInboundLedger::markComplete | ( | ) |
Record that every part has been fetched.
Definition at line 80 of file InboundLedger_test.cpp.
| void xrpl::test::TestableInboundLedger::signalDone | ( | ) |
Settle the acquisition and signal whatever is waiting on it.
Definition at line 90 of file InboundLedger_test.cpp.
| xrpl::InboundLedger::InboundLedger | ( | Application & | app, |
| UInt256 const & | hash, | ||
| std::uint32_t | seq, | ||
| Reason | reason, | ||
| ClockType & | clock, | ||
| std::unique_ptr< PeerSet > | peerSet, | ||
| std::chrono::milliseconds | retryInterval = kRetryInterval ) |
| app | The application to run in. |
| hash | The ledger to acquire. |
| seq | Its sequence, or zero if not known yet. |
| reason | Why it is being acquired. |
| clock | The clock touch() records against. |
| peerSet | Which peers to ask, and how to reach them. |
| retryInterval | How long to wait between retries. TimeoutCounter requires more than 10ms and less than 30s. |
Definition at line 62 of file InboundLedger.cpp.
|
inherited |
Definition at line 151 of file InboundLedger.cpp.
|
inherited |
Returns true if we got all the data.
Definition at line 81 of file InboundLedger.h.
|
inherited |
Returns false if we failed to get the data.
Definition at line 90 of file InboundLedger.h.
|
inherited |
The acquired ledger.
A failed acquisition may still hold a partially built ledger, which getJson() reports on, so ledger_ is kept while this answers nullptr.
Definition at line 105 of file InboundLedger.h.
|
inherited |
Definition at line 111 of file InboundLedger.h.
|
inherited |
Definition at line 164 of file InboundLedger.cpp.
|
inherited |
Definition at line 91 of file InboundLedger.cpp.
|
inherited |
Stash a TMLedgerData received from a peer for later processing Returns 'true' if we need to dispatch.
Definition at line 1108 of file InboundLedger.cpp.
|
inherited |
Return a json::ValueType::Object.
Definition at line 1370 of file InboundLedger.cpp.
|
inherited |
Process pending TMLedgerData Query the a random sample of the 'best' peers.
Definition at line 1323 of file InboundLedger.cpp.
|
inherited |
Definition at line 136 of file InboundLedger.h.
|
inherited |
Definition at line 142 of file InboundLedger.h.
|
protectedinherited |
Ask for more nodes, or judge what has been collected.
Request more nodes, perhaps from a specific peer.
| peer | The peer to ask, or nullptr to ask everyone being tracked. |
| reason | Why the acquisition is being triggered. |
Definition at line 504 of file InboundLedger.cpp.
|
protectedinherited |
Settle the acquisition and signal whatever is waiting on it.
Runs at most once. Call under mtx_, which the flags written here require.
Definition at line 436 of file InboundLedger.cpp.
|
privateinherited |
Definition at line 780 of file InboundLedger.cpp.
|
privateinherited |
Definition at line 1072 of file InboundLedger.cpp.
|
privateinherited |
Add more peers to the set, if possible.
Definition at line 416 of file InboundLedger.cpp.
|
privateinherited |
Definition at line 243 of file InboundLedger.cpp.
|
overrideprivatevirtualinherited |
Called with a lock by the PeerSet when the timer expires.
Implements xrpl::TimeoutCounter.
Definition at line 366 of file InboundLedger.cpp.
|
privateinherited |
Definition at line 143 of file InboundLedger.cpp.
|
overrideprivatevirtualinherited |
Return a weak pointer to this.
Implements xrpl::TimeoutCounter.
Definition at line 430 of file InboundLedger.cpp.
|
privateinherited |
Process one TMLedgerData Returns the number of useful nodes.
Definition at line 1136 of file InboundLedger.cpp.
|
privateinherited |
Build the ledger from a header a peer supplied.
Call with mtx_ held.
| data | The serialized header, without a hash prefix. |
Definition at line 841 of file InboundLedger.cpp.
|
privateinherited |
Fail the acquisition when the header's account hash is zero.
No ledger has an empty state map, so such a header cannot name a ledger. Both tryDB() and takeHeader() judge the header here.
Definition at line 819 of file InboundLedger.cpp.
|
privateinherited |
Process node data received from a peer Call with a lock.
Definition at line 889 of file InboundLedger.cpp.
|
privateinherited |
Process AS root node received from a peer Call with a lock.
Definition at line 1040 of file InboundLedger.cpp.
|
privateinherited |
Process AS root node received from a peer Call with a lock.
Definition at line 1004 of file InboundLedger.cpp.
|
privateinherited |
Definition at line 229 of file InboundLedger.cpp.
|
privateinherited |
Definition at line 235 of file InboundLedger.cpp.
|
virtualinherited |
Cancel the task by marking it as failed if the task is not done.
Definition at line 105 of file TimeoutCounter.cpp.
|
protectedinherited |
Schedule a call to queueJob() after timerInterval_.
Definition at line 40 of file TimeoutCounter.cpp.
|
protectedinherited |
Queue a job to call invokeOnTimer().
Definition at line 58 of file TimeoutCounter.cpp.
|
protectedinherited |
Definition at line 117 of file TimeoutCounter.h.
|
privateinherited |
Calls onTimer() if in the right state.
Only called by queueJob().
Definition at line 80 of file TimeoutCounter.cpp.
|
staticprivatenoexceptinherited |
Definition at line 113 of file CountedObject.h.
|
staticconstexprinherited |
How long to wait between retries, and so how long one timeout takes.
Definition at line 50 of file InboundLedger.h.
|
privateinherited |
Definition at line 227 of file InboundLedger.h.
|
privateinherited |
Definition at line 228 of file InboundLedger.h.
|
privateinherited |
Definition at line 230 of file InboundLedger.h.
|
privateinherited |
Definition at line 231 of file InboundLedger.h.
|
privateinherited |
Definition at line 232 of file InboundLedger.h.
|
privateinherited |
Definition at line 233 of file InboundLedger.h.
|
privateinherited |
Definition at line 234 of file InboundLedger.h.
|
privateinherited |
Definition at line 235 of file InboundLedger.h.
|
privateinherited |
Definition at line 236 of file InboundLedger.h.
|
privateinherited |
Definition at line 237 of file InboundLedger.h.
Definition at line 239 of file InboundLedger.h.
|
privateinherited |
Definition at line 241 of file InboundLedger.h.
|
privateinherited |
Definition at line 244 of file InboundLedger.h.
|
privateinherited |
Definition at line 246 of file InboundLedger.h.
|
privateinherited |
Definition at line 247 of file InboundLedger.h.
|
privateinherited |
Definition at line 248 of file InboundLedger.h.
|
protectedinherited |
Definition at line 124 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 125 of file TimeoutCounter.h.
|
mutableprotectedinherited |
Definition at line 126 of file TimeoutCounter.h.
|
protectedinherited |
The hash of the object (in practice, always a ledger) we are trying to fetch.
Definition at line 132 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 133 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 134 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 135 of file TimeoutCounter.h.
|
protectedinherited |
Whether forward progress has been made.
Definition at line 139 of file TimeoutCounter.h.
|
protectedinherited |
The minimum time to wait between calls to execute().
Definition at line 143 of file TimeoutCounter.h.
|
protectedinherited |
Definition at line 145 of file TimeoutCounter.h.
|
privateinherited |
Definition at line 155 of file TimeoutCounter.h.
|
inherited |
Definition at line 138 of file CountedObject.h.