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.getJournal("NodeFamily"))
13 , fbCache_(
14 std::make_shared<FullBelowCache>(
15 "Node family full below cache",
16 stopwatch(),
17 app.getJournal("NodeFamilyFulLBelowCache"),
18 cm.collector(),
21 , tnCache_(
22 std::make_shared<TreeNodeCache>(
23 "Node family tree node cache",
24 app.config().getValueFor(SizedItem::treeCacheSize),
25 std::chrono::seconds(app.config().getValueFor(SizedItem::treeCacheAge)),
26 stopwatch(),
27 j_))
28{
29}
30
31void
33{
34 fbCache_->sweep();
35 tnCache_->sweep();
36}
37
38void
40{
41 {
42 std::lock_guard const lock(maxSeqMutex_);
43 maxSeq_ = 0;
44 }
45
46 fbCache_->reset();
47 tnCache_->reset();
48}
49
50void
52{
53 JLOG(j_.error()) << "Missing node in " << seq;
55 if (maxSeq_ == 0)
56 {
57 maxSeq_ = seq;
58
59 do
60 {
61 // Try to acquire the most recent missing ledger
62 seq = maxSeq_;
63
64 lock.unlock();
65
66 // This can invoke the missing node handler
68
69 lock.lock();
70 } while (maxSeq_ != seq);
71 }
72 else if (maxSeq_ < seq)
73 {
74 // We found a more recent ledger with a missing node
75 maxSeq_ = seq;
76 }
77}
78
79void
81{
82 if (hash.isNonZero())
83 {
84 JLOG(j_.error()) << "Missing node in " << to_string(hash);
85
87 }
88}
89
90} // 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:75
Application & app_
Definition NodeFamily.h:70
void acquire(uint256 const &hash, std::uint32_t seq)
void sweep() override
std::mutex maxSeqMutex_
Definition NodeFamily.h:79
NodeFamily()=delete
std::shared_ptr< FullBelowCache > fbCache_
Definition NodeFamily.h:74
beast::Journal const j_
Definition NodeFamily.h:72
LedgerIndex maxSeq_
Definition NodeFamily.h:78
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:42
bool isNonZero() const
Definition base_uint.h:518
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:5
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:602
SizedItem
Definition Config.h:27
constexpr std::chrono::seconds fullBelowExpiration
constexpr std::size_t fullBelowTargetSize