Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
CacheUpdater.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2025, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include "data/LedgerCacheInterface.hpp"
23#include "data/Types.hpp"
24#include "etlng/CacheUpdaterInterface.hpp"
25#include "etlng/Models.hpp"
26#include "util/log/Logger.hpp"
27
28#include <cstdint>
29#include <functional>
30#include <vector>
31
32namespace etlng::impl {
33
35 std::reference_wrapper<data::LedgerCacheInterface> cache_;
36
37 util::Logger log_{"ETL"};
38
39public:
40 CacheUpdater(data::LedgerCacheInterface& cache) : cache_{cache}
41 {
42 }
43
44 void
45 update(model::LedgerData const& data) override
46 {
47 cache_.get().update(data.objects, data.seq);
48 }
49
50 void
51 update(uint32_t seq, std::vector<data::LedgerObject> const& objs) override
52 {
53 cache_.get().update(objs, seq);
54 }
55
56 void
57 update(uint32_t seq, std::vector<model::Object> const& objs) override
58 {
59 cache_.get().update(objs, seq);
60 }
61
62 void
63 setFull() override
64 {
65 cache_.get().setFull();
66 }
67};
68
69} // namespace etlng::impl
Cache for an entire ledger.
Definition LedgerCacheInterface.hpp:38
Definition CacheUpdater.hpp:34
void update(uint32_t seq, std::vector< model::Object > const &objs) override
Update the cache with model objects at a specific sequence.
Definition CacheUpdater.hpp:57
void update(model::LedgerData const &data) override
Update the cache with ledger data.
Definition CacheUpdater.hpp:45
void setFull() override
Mark the cache as fully loaded.
Definition CacheUpdater.hpp:63
void update(uint32_t seq, std::vector< data::LedgerObject > const &objs) override
Update the cache with ledger objects at a specific sequence.
Definition CacheUpdater.hpp:51
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:111
This namespace implements the data access layer and related components.
Definition AmendmentCenter.cpp:70
An interface for the Cache Updater.
Definition CacheUpdaterInterface.hpp:33
Represents an entire ledger diff worth of transactions and objects.
Definition Models.hpp:143