xrpld
Loading...
Searching...
No Matches
InboundLedgers.h
1#pragma once
2
3#include <xrpld/app/ledger/InboundLedger.h>
4#include <xrpld/app/main/Application.h>
5#include <xrpld/overlay/Peer.h>
6
7#include <xrpl/basics/base_uint.h>
8#include <xrpl/beast/clock/abstract_clock.h>
9#include <xrpl/beast/insight/Collector.h>
10#include <xrpl/json/json_value.h>
11#include <xrpl/ledger/Ledger.h>
12#include <xrpl/protocol/RippleLedgerHash.h>
13
14#include <xrpl.pb.h>
15
16#include <chrono>
17#include <cstddef>
18#include <cstdint>
19#include <memory>
20
21namespace xrpl {
22
29{
30public:
32
33 virtual ~InboundLedgers() = default;
34
35 // Callers should use this if they possibly need an authoritative
36 // response immediately.
39
40 // Callers should use this if they are known to be executing on the Job
41 // Queue. TODO review whether all callers of acquire() can use this
42 // instead. Inbound ledger acquisition is asynchronous anyway.
43 virtual void
45
47 find(LedgerHash const& hash) = 0;
48
49 // VFALCO TODO Remove the dependency on the Peer object.
50 //
51 virtual bool
53 LedgerHash const& ledgerHash,
56
57 virtual void
59
60 virtual void
61 logFailure(uint256 const& h, std::uint32_t seq) = 0;
62
63 virtual bool
64 isFailure(uint256 const& h) = 0;
65
66 virtual void
68
69 virtual json::Value
70 getInfo() = 0;
71
75 virtual std::size_t
76 fetchRate() = 0;
77
81 virtual void
83
84 virtual void
86 virtual void
87 sweep() = 0;
88
89 virtual void
90 stop() = 0;
91
92 virtual std::size_t
93 cacheSize() = 0;
94};
95
98 Application& app,
100 beast::insight::Collector::ptr const& collector);
101
102} // namespace xrpl
Abstract interface to a clock.
std::shared_ptr< Collector > ptr
Definition Collector.h:29
Represents a JSON value.
Definition json_value.h:117
Manages the lifetime of inbound ledgers.
beast::AbstractClock< std::chrono::steady_clock > clock_type
virtual void gotStaleData(std::shared_ptr< protocol::TMLedgerData > packet)=0
virtual void onLedgerFetched()=0
Called when a complete ledger is obtained.
virtual void logFailure(uint256 const &h, std::uint32_t seq)=0
virtual void acquireAsync(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason reason)=0
virtual std::size_t fetchRate()=0
Returns the rate of historical ledger fetches per minute.
virtual bool gotLedgerData(LedgerHash const &ledgerHash, std::shared_ptr< Peer >, std::shared_ptr< protocol::TMLedgerData >)=0
virtual json::Value getInfo()=0
virtual void gotFetchPack()=0
virtual ~InboundLedgers()=default
virtual void clearFailures()=0
virtual void sweep()=0
virtual bool isFailure(uint256 const &h)=0
virtual std::size_t cacheSize()=0
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
virtual std::shared_ptr< InboundLedger > find(LedgerHash const &hash)=0
virtual void stop()=0
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
uint256 LedgerHash
std::unique_ptr< InboundLedgers > makeInboundLedgers(Application &app, InboundLedgers::clock_type &clock, beast::insight::Collector::ptr const &collector)
BaseUInt< 256 > uint256
Definition base_uint.h:580