rippled
Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Attributes | List of all members
ripple::InboundLedgersImp Class Reference
Inheritance diagram for ripple::InboundLedgersImp:
Inheritance graph
[legend]
Collaboration diagram for ripple::InboundLedgersImp:
Collaboration graph
[legend]

Public Types

using clock_type = beast::abstract_clock< std::chrono::steady_clock >
 

Public Member Functions

 InboundLedgersImp (Application &app, clock_type &clock, beast::insight::Collector::ptr const &collector, std::unique_ptr< PeerSetBuilder > peerSetBuilder)
 
std::shared_ptr< Ledger const > acquire (uint256 const &hash, std::uint32_t seq, InboundLedger::Reason reason) override
 
std::shared_ptr< InboundLedgerfind (uint256 const &hash) override
 
bool gotLedgerData (LedgerHash const &hash, std::shared_ptr< Peer > peer, std::shared_ptr< protocol::TMLedgerData > packet) override
 We received a TMLedgerData from a peer. More...
 
void logFailure (uint256 const &h, std::uint32_t seq) override
 
bool isFailure (uint256 const &h) override
 
void gotStaleData (std::shared_ptr< protocol::TMLedgerData > packet_ptr) override
 We got some data for a ledger we are no longer acquiring Since we paid the price to receive it, we might as well stash it in case we need it. More...
 
void clearFailures () override
 
std::size_t fetchRate () override
 Returns the rate of historical ledger fetches per minute. More...
 
void onLedgerFetched () override
 Called when a complete ledger is obtained. More...
 
Json::Value getInfo () override
 
void gotFetchPack () override
 
void sweep () override
 
void stop () override
 

Static Public Attributes

static constexpr const std::chrono::minutes kReacquireInterval {5}
 

Private Types

using ScopedLockType = std::unique_lock< std::recursive_mutex >
 
using MapType = hash_map< uint256, std::shared_ptr< InboundLedger > >
 

Private Attributes

Applicationapp_
 
std::mutex fetchRateMutex_
 
DecayWindow< 30, clock_typefetchRate_
 
const beast::Journal j_
 
clock_typem_clock
 
std::recursive_mutex mLock
 
bool stopping_ = false
 
MapType mLedgers
 
beast::aged_map< uint256, std::uint32_tmRecentFailures
 
beast::insight::Counter mCounter
 
std::unique_ptr< PeerSetBuildermPeerSetBuilder
 

Detailed Description

Definition at line 37 of file InboundLedgers.cpp.

Member Typedef Documentation

◆ ScopedLockType

Definition at line 417 of file InboundLedgers.cpp.

◆ MapType

Definition at line 421 of file InboundLedgers.cpp.

◆ clock_type

Definition at line 36 of file InboundLedgers.h.

Constructor & Destructor Documentation

◆ InboundLedgersImp()

ripple::InboundLedgersImp::InboundLedgersImp ( Application app,
clock_type clock,
beast::insight::Collector::ptr const &  collector,
std::unique_ptr< PeerSetBuilder peerSetBuilder 
)

Definition at line 50 of file InboundLedgers.cpp.

Member Function Documentation

◆ acquire()

std::shared_ptr<Ledger const> ripple::InboundLedgersImp::acquire ( uint256 const &  hash,
std::uint32_t  seq,
InboundLedger::Reason  reason 
)
overridevirtual

Implements ripple::InboundLedgers.

Definition at line 67 of file InboundLedgers.cpp.

Here is the call graph for this function:

◆ find()

std::shared_ptr<InboundLedger> ripple::InboundLedgersImp::find ( uint256 const &  hash)
overridevirtual

Implements ripple::InboundLedgers.

Definition at line 145 of file InboundLedgers.cpp.

◆ gotLedgerData()

bool ripple::InboundLedgersImp::gotLedgerData ( LedgerHash const &  hash,
std::shared_ptr< Peer peer,
std::shared_ptr< protocol::TMLedgerData >  packet 
)
overridevirtual

We received a TMLedgerData from a peer.

Implements ripple::InboundLedgers.

Definition at line 179 of file InboundLedgers.cpp.

◆ logFailure()

void ripple::InboundLedgersImp::logFailure ( uint256 const &  h,
std::uint32_t  seq 
)
overridevirtual

Implements ripple::InboundLedgers.

Definition at line 217 of file InboundLedgers.cpp.

◆ isFailure()

bool ripple::InboundLedgersImp::isFailure ( uint256 const &  h)
overridevirtual

Implements ripple::InboundLedgers.

Definition at line 225 of file InboundLedgers.cpp.

◆ gotStaleData()

void ripple::InboundLedgersImp::gotStaleData ( std::shared_ptr< protocol::TMLedgerData >  packet_ptr)
overridevirtual

We got some data for a ledger we are no longer acquiring Since we paid the price to receive it, we might as well stash it in case we need it.

Nodes are received in wire format and must be stashed/hashed in prefix format

Implements ripple::InboundLedgers.

Definition at line 240 of file InboundLedgers.cpp.

◆ clearFailures()

void ripple::InboundLedgersImp::clearFailures ( )
overridevirtual

Implements ripple::InboundLedgers.

Definition at line 272 of file InboundLedgers.cpp.

◆ fetchRate()

std::size_t ripple::InboundLedgersImp::fetchRate ( )
overridevirtual

Returns the rate of historical ledger fetches per minute.

Implements ripple::InboundLedgers.

Definition at line 281 of file InboundLedgers.cpp.

◆ onLedgerFetched()

void ripple::InboundLedgersImp::onLedgerFetched ( )
overridevirtual

Called when a complete ledger is obtained.

Implements ripple::InboundLedgers.

Definition at line 290 of file InboundLedgers.cpp.

◆ getInfo()

Json::Value ripple::InboundLedgersImp::getInfo ( )
overridevirtual

Implements ripple::InboundLedgers.

Definition at line 297 of file InboundLedgers.cpp.

◆ gotFetchPack()

void ripple::InboundLedgersImp::gotFetchPack ( )
overridevirtual

Implements ripple::InboundLedgers.

Definition at line 335 of file InboundLedgers.cpp.

◆ sweep()

void ripple::InboundLedgersImp::sweep ( )
overridevirtual

Implements ripple::InboundLedgers.

Definition at line 356 of file InboundLedgers.cpp.

◆ stop()

void ripple::InboundLedgersImp::stop ( )
overridevirtual

Implements ripple::InboundLedgers.

Definition at line 406 of file InboundLedgers.cpp.

Member Data Documentation

◆ app_

Application& ripple::InboundLedgersImp::app_
private

Definition at line 40 of file InboundLedgers.cpp.

◆ fetchRateMutex_

std::mutex ripple::InboundLedgersImp::fetchRateMutex_
private

Definition at line 41 of file InboundLedgers.cpp.

◆ fetchRate_

DecayWindow<30, clock_type> ripple::InboundLedgersImp::fetchRate_
private

Definition at line 43 of file InboundLedgers.cpp.

◆ j_

const beast::Journal ripple::InboundLedgersImp::j_
private

Definition at line 44 of file InboundLedgers.cpp.

◆ kReacquireInterval

constexpr const std::chrono::minutes ripple::InboundLedgersImp::kReacquireInterval {5}
staticconstexpr

Definition at line 48 of file InboundLedgers.cpp.

◆ m_clock

clock_type& ripple::InboundLedgersImp::m_clock
private

Definition at line 415 of file InboundLedgers.cpp.

◆ mLock

std::recursive_mutex ripple::InboundLedgersImp::mLock
private

Definition at line 418 of file InboundLedgers.cpp.

◆ stopping_

bool ripple::InboundLedgersImp::stopping_ = false
private

Definition at line 420 of file InboundLedgers.cpp.

◆ mLedgers

MapType ripple::InboundLedgersImp::mLedgers
private

Definition at line 422 of file InboundLedgers.cpp.

◆ mRecentFailures

beast::aged_map<uint256, std::uint32_t> ripple::InboundLedgersImp::mRecentFailures
private

Definition at line 424 of file InboundLedgers.cpp.

◆ mCounter

beast::insight::Counter ripple::InboundLedgersImp::mCounter
private

Definition at line 426 of file InboundLedgers.cpp.

◆ mPeerSetBuilder

std::unique_ptr<PeerSetBuilder> ripple::InboundLedgersImp::mPeerSetBuilder
private

Definition at line 428 of file InboundLedgers.cpp.