rippled
Loading...
Searching...
No Matches
NodeFamily.cpp
1#include <xrpld/app/ledger/LedgerMaster.h>
2#include <xrpld/app/main/Application.h>
3#include <xrpld/app/main/CollectorManager.h>
4#include <xrpld/app/main/Tuning.h>
5#include <xrpld/shamap/NodeFamily.h>
6
7namespace xrpl {
8
10 : app_(app)
11 , db_(app.getNodeStore())
12 , j_(app.journal("NodeFamily"))
13 , fbCache_(std::make_shared<FullBelowCache>(
14 "Node family full below cache",
15 stopwatch(),
16 app.journal("NodeFamilyFulLBelowCache"),
17 cm.collector(),
20 , tnCache_(std::make_shared<TreeNodeCache>(
21 "Node family tree node cache",
22 app.config().getValueFor(SizedItem::treeCacheSize),
23 std::chrono::seconds(app.config().getValueFor(SizedItem::treeCacheAge)),
24 stopwatch(),
25 j_))
26{
27}
28
29void
31{
32 fbCache_->sweep();
33 tnCache_->sweep();
34}
35
36void
38{
39 {
41 maxSeq_ = 0;
42 }
43
44 fbCache_->reset();
45 tnCache_->reset();
46}
47
48void
50{
51 JLOG(j_.error()) << "Missing node in " << seq;
53 if (maxSeq_ == 0)
54 {
55 maxSeq_ = seq;
56
57 do
58 {
59 // Try to acquire the most recent missing ledger
60 seq = maxSeq_;
61
62 lock.unlock();
63
64 // This can invoke the missing node handler
66
67 lock.lock();
68 } while (maxSeq_ != seq);
69 }
70 else if (maxSeq_ < seq)
71 {
72 // We found a more recent ledger with a missing node
73 maxSeq_ = seq;
74 }
75}
76
77void
79{
80 if (hash.isNonZero())
81 {
82 JLOG(j_.error()) << "Missing node in " << to_string(hash);
83
85 }
86}
87
88} // namespace xrpl
Stream error() const
Definition Journal.h:319
Provides the beast::insight::Collector service.
virtual std::shared_ptr< Ledger const > acquire(uint256 const &hash, std::uint32_t seq, InboundLedger::Reason)=0
uint256 getHashBySeq(std::uint32_t index)
Get a ledger's hash by sequence number using the cache.
void reset() override
std::shared_ptr< TreeNodeCache > tnCache_
Definition NodeFamily.h:76
Application & app_
Definition NodeFamily.h:71
void acquire(uint256 const &hash, std::uint32_t seq)
void sweep() override
std::mutex maxSeqMutex_
Definition NodeFamily.h:80
NodeFamily()=delete
std::shared_ptr< FullBelowCache > fbCache_
Definition NodeFamily.h:75
beast::Journal const j_
Definition NodeFamily.h:73
LedgerIndex maxSeq_
Definition NodeFamily.h:79
void missingNodeAcquireBySeq(std::uint32_t seq, uint256 const &hash) override
Acquire ledger that has a missing node by ledger sequence.
virtual InboundLedgers & getInboundLedgers()=0
virtual LedgerMaster & getLedgerMaster()=0
Map/cache combination.
Definition TaggedCache.h:43
bool isNonZero() const
Definition base_uint.h:514
Remembers which tree keys have all descendants resident.
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Stopwatch & stopwatch()
Returns an instance of a wall clock.
Definition chrono.h:94
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:598
SizedItem
Definition Config.h:25
constexpr std::chrono::seconds fullBelowExpiration
constexpr std::size_t fullBelowTargetSize