1919
2020#pragma once
2121
22+ #include " data/LedgerCacheInterface.hpp"
2223#include " util/Taggable.hpp"
2324#include " util/log/Logger.hpp"
2425#include " web/AdminVerificationStrategy.hpp"
@@ -85,6 +86,7 @@ class Detector : public std::enable_shared_from_this<Detector<PlainSessionType,
8586 std::reference_wrapper<util::TagDecoratorFactory const > tagFactory_;
8687 std::reference_wrapper<dosguard::DOSGuardInterface> const dosGuard_;
8788 std::shared_ptr<HandlerType> const handler_;
89+ std::reference_wrapper<data::LedgerCacheInterface const > cache_;
8890 boost::beast::flat_buffer buffer_;
8991 std::shared_ptr<AdminVerificationStrategy> const adminVerification_;
9092 std::uint32_t maxWsSendingQueueSize_;
@@ -99,6 +101,7 @@ class Detector : public std::enable_shared_from_this<Detector<PlainSessionType,
99101 * @param tagFactory A factory that is used to generate tags to track requests and sessions
100102 * @param dosGuard The denial of service guard to use
101103 * @param handler The server handler to use
104+ * @param cache The ledger cache to use
102105 * @param adminVerification The admin verification strategy to use
103106 * @param maxWsSendingQueueSize The maximum size of the sending queue for websocket
104107 * @param proxyIpResolver The client ip resolver if a request was forwarded by a proxy
@@ -109,6 +112,7 @@ class Detector : public std::enable_shared_from_this<Detector<PlainSessionType,
109112 std::reference_wrapper<util::TagDecoratorFactory const > tagFactory,
110113 std::reference_wrapper<dosguard::DOSGuardInterface> dosGuard,
111114 std::shared_ptr<HandlerType> handler,
115+ std::reference_wrapper<data::LedgerCacheInterface const > cache,
112116 std::shared_ptr<AdminVerificationStrategy> adminVerification,
113117 std::uint32_t maxWsSendingQueueSize,
114118 std::shared_ptr<ProxyIpResolver> proxyIpResolver
@@ -118,6 +122,7 @@ class Detector : public std::enable_shared_from_this<Detector<PlainSessionType,
118122 , tagFactory_(std::cref(tagFactory))
119123 , dosGuard_(dosGuard)
120124 , handler_(std::move(handler))
125+ , cache_(cache)
121126 , adminVerification_(std::move(adminVerification))
122127 , maxWsSendingQueueSize_(maxWsSendingQueueSize)
123128 , proxyIpResolver_(std::move(proxyIpResolver))
@@ -179,6 +184,7 @@ class Detector : public std::enable_shared_from_this<Detector<PlainSessionType,
179184 tagFactory_,
180185 dosGuard_,
181186 handler_,
187+ cache_,
182188 std::move (buffer_),
183189 maxWsSendingQueueSize_
184190 )
@@ -194,6 +200,7 @@ class Detector : public std::enable_shared_from_this<Detector<PlainSessionType,
194200 tagFactory_,
195201 dosGuard_,
196202 handler_,
203+ cache_,
197204 std::move (buffer_),
198205 maxWsSendingQueueSize_
199206 )
@@ -223,6 +230,7 @@ class Server : public std::enable_shared_from_this<Server<PlainSessionType, SslS
223230 util::TagDecoratorFactory tagFactory_;
224231 std::reference_wrapper<dosguard::DOSGuardInterface> dosGuard_;
225232 std::shared_ptr<HandlerType> handler_;
233+ std::reference_wrapper<data::LedgerCacheInterface const > cache_;
226234 tcp::acceptor acceptor_;
227235 std::shared_ptr<AdminVerificationStrategy> adminVerification_;
228236 std::uint32_t maxWsSendingQueueSize_;
@@ -238,6 +246,7 @@ class Server : public std::enable_shared_from_this<Server<PlainSessionType, SslS
238246 * @param tagFactory A factory that is used to generate tags to track requests and sessions
239247 * @param dosGuard The denial of service guard to use
240248 * @param handler The server handler to use
249+ * @param cache The ledger cache to use
241250 * @param adminVerification The admin verification strategy to use
242251 * @param maxWsSendingQueueSize The maximum size of the sending queue for websocket
243252 * @param proxyIpResolver The client ip resolver if a request was forwarded by a proxy
@@ -249,6 +258,7 @@ class Server : public std::enable_shared_from_this<Server<PlainSessionType, SslS
249258 util::TagDecoratorFactory tagFactory,
250259 dosguard::DOSGuardInterface& dosGuard,
251260 std::shared_ptr<HandlerType> handler,
261+ std::reference_wrapper<data::LedgerCacheInterface const > cache,
252262 std::shared_ptr<AdminVerificationStrategy> adminVerification,
253263 std::uint32_t maxWsSendingQueueSize,
254264 ProxyIpResolver proxyIpResolver
@@ -258,6 +268,7 @@ class Server : public std::enable_shared_from_this<Server<PlainSessionType, SslS
258268 , tagFactory_(tagFactory)
259269 , dosGuard_(std::ref(dosGuard))
260270 , handler_(std::move(handler))
271+ , cache_(cache)
261272 , acceptor_(boost::asio::make_strand(ioc))
262273 , adminVerification_(std::move(adminVerification))
263274 , maxWsSendingQueueSize_(maxWsSendingQueueSize)
@@ -320,6 +331,7 @@ class Server : public std::enable_shared_from_this<Server<PlainSessionType, SslS
320331 std::cref (tagFactory_),
321332 dosGuard_,
322333 handler_,
334+ cache_,
323335 adminVerification_,
324336 maxWsSendingQueueSize_,
325337 proxyIpResolver_
@@ -343,6 +355,7 @@ using HttpServer = Server<HttpSession, SslHttpSession, HandlerType>;
343355 * @param ioc The server will run under this io_context
344356 * @param dosGuard The dos guard to protect the server
345357 * @param handler The handler to process the request
358+ * @param cache The ledger cache to use
346359 * @return The server instance
347360 */
348361template <typename HandlerType>
@@ -351,7 +364,8 @@ makeHttpServer(
351364 util::config::ClioConfigDefinition const & config,
352365 boost::asio::io_context& ioc,
353366 dosguard::DOSGuardInterface& dosGuard,
354- std::shared_ptr<HandlerType> const & handler
367+ std::shared_ptr<HandlerType> const & handler,
368+ std::reference_wrapper<data::LedgerCacheInterface const > cache
355369)
356370{
357371 static util::Logger const log{" WebServer" }; // NOLINT(readability-identifier-naming)
@@ -385,6 +399,7 @@ makeHttpServer(
385399 util::TagDecoratorFactory (config),
386400 dosGuard,
387401 handler,
402+ cache,
388403 std::move (expectedAdminVerification).value (),
389404 maxWsSendingQueueSize,
390405 std::move (proxyIpResolver)
0 commit comments