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 ripple {
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(
24 app.config().getValueFor(SizedItem::treeCacheAge)),
25 stopwatch(),
26 j_))
27{
28}
29
30void
32{
33 fbCache_->sweep();
34 tnCache_->sweep();
35}
36
37void
39{
40 {
42 maxSeq_ = 0;
43 }
44
45 fbCache_->reset();
46 tnCache_->reset();
47}
48
49void
51{
52 JLOG(j_.error()) << "Missing node in " << seq;
54 if (maxSeq_ == 0)
55 {
56 maxSeq_ = seq;
57
58 do
59 {
60 // Try to acquire the most recent missing ledger
61 seq = maxSeq_;
62
63 lock.unlock();
64
65 // This can invoke the missing node handler
67
68 lock.lock();
69 } while (maxSeq_ != seq);
70 }
71 else if (maxSeq_ < seq)
72 {
73 // We found a more recent ledger with a missing node
74 maxSeq_ = seq;
75 }
76}
77
78void
80{
81 if (hash.isNonZero())
82 {
83 JLOG(j_.error()) << "Missing node in " << to_string(hash);
84
87 }
88}
89
90} // namespace ripple
Stream error() const
Definition Journal.h:327
virtual InboundLedgers & getInboundLedgers()=0
virtual LedgerMaster & getLedgerMaster()=0
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.
LedgerIndex maxSeq_
Definition NodeFamily.h:79
std::shared_ptr< TreeNodeCache > tnCache_
Definition NodeFamily.h:76
void sweep() override
void acquire(uint256 const &hash, std::uint32_t seq)
std::shared_ptr< FullBelowCache > fbCache_
Definition NodeFamily.h:75
beast::Journal const j_
Definition NodeFamily.h:73
Application & app_
Definition NodeFamily.h:71
std::mutex maxSeqMutex_
Definition NodeFamily.h:80
void reset() override
void missingNodeAcquireBySeq(std::uint32_t seq, uint256 const &hash) override
Acquire ledger that has a missing node by ledger sequence.
Map/cache combination.
Definition TaggedCache.h:43
bool isNonZero() const
Definition base_uint.h:526
Remembers which tree keys have all descendants resident.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
SizedItem
Definition Config.h:25
constexpr std::chrono::seconds fullBelowExpiration
Stopwatch & stopwatch()
Returns an instance of a wall clock.
Definition chrono.h:100
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:611
constexpr std::size_t fullBelowTargetSize
STL namespace.