20#include <xrpld/app/ledger/InboundLedgers.h> 
   21#include <xrpld/app/ledger/LedgerMaster.h> 
   22#include <xrpld/app/main/Application.h> 
   23#include <xrpld/app/misc/NetworkOPs.h> 
   24#include <xrpld/core/JobQueue.h> 
   25#include <xrpld/perflog/PerfLog.h> 
   27#include <xrpl/basics/DecayingSample.h> 
   28#include <xrpl/basics/Log.h> 
   29#include <xrpl/basics/scope.h> 
   30#include <xrpl/beast/container/aged_map.h> 
   31#include <xrpl/protocol/jss.h> 
   60        , 
j_(app.journal(
"InboundLedger"))
 
   63        , 
mCounter(collector->make_counter(
"ledger_fetches"))
 
 
   78                "ripple::InboundLedgersImp::acquire::doAcquire : nonzero hash");
 
  116            if (inbound->isFailed())
 
  120                inbound->update(seq);
 
  122            if (!inbound->isComplete())
 
  125            return inbound->getLedger();
 
  127        using namespace std::chrono_literals;
 
  129            doAcquire, 
"InboundLedgersImp::acquire", 500ms, 
j_);
 
 
  152                << 
"Exception thrown for acquiring new inbound ledger " << hash
 
  158                << 
"Unknown exception thrown for acquiring new inbound ledger " 
 
  169            "ripple::InboundLedgersImp::find : nonzero input");
 
 
  206        if (
auto ledger = 
find(hash))
 
  208            JLOG(
j_.
trace()) << 
"Got data (" << packet->nodes().size()
 
  209                             << 
") for acquiring ledger: " << hash;
 
  222        JLOG(
j_.
trace()) << 
"Got data for ledger " << hash
 
  223                         << 
" which we're no longer acquiring";
 
  227        if (packet->type() == protocol::liAS_NODE)
 
 
  267            for (
int i = 0; i < packet_ptr->nodes().size(); ++i)
 
  269                auto const& node = packet_ptr->nodes(i);
 
  271                if (!node.has_nodeid() || !node.has_nodedata())
 
  281                newNode->serializeWithPrefix(s);
 
  284                    newNode->getHash().as_uint256(),
 
 
  333                    "ripple::InboundLedgersImp::getInfo : non-null ledger");
 
  341                    ret[
to_string(it.first)][jss::failed] = 
true;
 
  345        for (
auto const& it : acqs)
 
  352                ret[
to_string(it.first)] = it.second->getJson(0);
 
 
  370                    "ripple::InboundLedgersImp::gotFetchPack : non-null " 
  376        for (
auto const& 
acquire : acquires)
 
 
  400                auto const la = it->second->getLastAction();
 
  424            << 
"Swept " << stuffToSweep.
size() << 
" out of " << total
 
  425            << 
" inbound ledgers. Duration: " 
  426            << std::chrono::duration_cast<std::chrono::milliseconds>(
 
 
 
A generic endpoint for log messages.
 
Stream trace() const
Severity stream access functions.
 
virtual time_point now() const =0
Returns the current time.
 
Associative container where each element is also indexed by time.
 
A metric for measuring an integral value.
 
virtual JobQueue & getJobQueue()=0
 
virtual NetworkOPs & getOPs()=0
 
virtual LedgerMaster & getLedgerMaster()=0
 
Sampling function using exponential decay to provide a continuous value.
 
double value(time_point now)
 
void add(double value, time_point now)
 
void clearFailures() override
 
DecayWindow< 30, clock_type > fetchRate_
 
std::size_t cacheSize() override
 
std::recursive_mutex mLock
 
void gotFetchPack() override
 
Json::Value getInfo() override
 
void logFailure(uint256 const &h, std::uint32_t seq) 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,...
 
beast::aged_map< uint256, std::uint32_t > mRecentFailures
 
std::set< uint256 > pendingAcquires_
 
beast::insight::Counter mCounter
 
std::unique_ptr< PeerSetBuilder > mPeerSetBuilder
 
std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason reason) override
 
std::mutex fetchRateMutex_
 
void acquireAsync(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason reason) override
 
InboundLedgersImp(Application &app, clock_type &clock, beast::insight::Collector::ptr const &collector, std::unique_ptr< PeerSetBuilder > peerSetBuilder)
 
static constexpr std::chrono::minutes const kReacquireInterval
 
std::size_t fetchRate() override
Returns the rate of historical ledger fetches per minute.
 
std::shared_ptr< InboundLedger > find(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.
 
void onLedgerFetched() override
Called when a complete ledger is obtained.
 
std::mutex acquiresMutex_
 
bool isFailure(uint256 const &h) override
 
Manages the lifetime of inbound ledgers.
 
bool addJob(JobType type, std::string const &name, JobHandler &&jobHandler)
Adds a job to the JobQueue.
 
void addFetchPack(uint256 const &hash, std::shared_ptr< Blob > data)
 
virtual bool isNeedNetworkLedger()=0
 
static intr_ptr::SharedPtr< SHAMapTreeNode > makeFromWire(Slice rawNode)
 
Automatically unlocks and re-locks a unique_lock object.
 
@ objectValue
object value (collection of name/value pairs).
 
std::enable_if< is_aged_container< AgedContainer >::value, std::size_t >::type expire(AgedContainer &c, std::chrono::duration< Rep, Period > const &age)
Expire aged container items past the specified age.
 
auto measureDurationAndLog(Func &&func, std::string const &actionDescription, std::chrono::duration< Rep, Period > maxDelay, beast::Journal const &journal)
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
std::unique_ptr< PeerSetBuilder > make_PeerSetBuilder(Application &app)
 
std::unique_ptr< InboundLedgers > make_InboundLedgers(Application &app, InboundLedgers::clock_type &clock, beast::insight::Collector::ptr const &collector)
 
std::enable_if_t< std::is_same< T, char >::value||std::is_same< T, unsigned char >::value, Slice > makeSlice(std::array< T, N > const &a)
 
std::string to_string(base_uint< Bits, Tag > const &a)