20 #ifndef RIPPLE_APP_MISC_VALIDATORSITE_H_INCLUDED
21 #define RIPPLE_APP_MISC_VALIDATORSITE_H_INCLUDED
23 #include <ripple/app/main/Application.h>
24 #include <ripple/app/misc/ValidatorList.h>
25 #include <ripple/app/misc/detail/Work.h>
26 #include <ripple/basics/Log.h>
27 #include <ripple/basics/StringUtilities.h>
28 #include <ripple/core/Config.h>
29 #include <ripple/json/json_value.h>
31 #include <boost/asio.hpp>
127 boost::asio::basic_waitable_timer<clock_type>
timer_;
223 boost::system::error_code
const& ec,
231 boost::system::error_code
const& ec,
std::chrono::minutes refreshInterval
boost::asio::basic_waitable_timer< clock_type > timer_
std::optional< Status > lastRefreshStatus
boost::asio::ip::tcp::endpoint endpoint_type
void stop()
Stop fetching lists from sites.
void onRequestTimeout(std::size_t siteIdx, error_code const &ec)
request took too long
std::weak_ptr< detail::Work > work_
bool lastRequestSuccessful
void makeRequest(std::shared_ptr< Site::Resource > resource, std::size_t siteIdx, std::lock_guard< std::mutex > const &)
Initiate request to given resource.
void onSiteFetch(boost::system::error_code const &ec, endpoint_type const &endpoint, detail::response_type &&res, std::size_t siteIdx)
Store latest list fetched from site.
std::atomic< bool > fetching_
void setTimer(std::lock_guard< std::mutex > const &, std::lock_guard< std::mutex > const &)
Queue next site to be fetched lock over site_mutex_ and state_mutex_ required.
boost::beast::http::response< boost::beast::http::string_body > response_type
clock_type::time_point refreshed
std::atomic< bool > pending_
Json::Value getJson() const
Return JSON representation of configured validator sites.
std::condition_variable cv_
void parseJsonResponse(std::string const &res, std::size_t siteIdx, std::lock_guard< std::mutex > const &)
Parse json response from validator list site.
A generic endpoint for log messages.
void join()
Wait for current fetches from sites to complete.
std::shared_ptr< Site::Resource > processRedirect(detail::response_type &res, std::size_t siteIdx, std::lock_guard< std::mutex > const &)
Interpret a redirect response.
unsigned short redirCount
std::vector< Site > sites_
clock_type::time_point nextRefresh
const std::chrono::seconds requestTimeout_
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::shared_ptr< Resource > activeResource
the active resource being requested.
Resource(std::string uri_)
void onTextFetch(boost::system::error_code const &ec, std::string const &res, std::size_t siteIdx)
Store latest list fetched from anywhere.
ListDisposition disposition
std::shared_ptr< Resource > loadedResource
the original uri as loaded from config
std::atomic< bool > stopping_
ValidatorSite(Application &app, std::optional< beast::Journal > j=std::nullopt, std::chrono::seconds timeout=std::chrono::seconds{20})
void start()
Start fetching lists from sites.
void onTimer(std::size_t siteIdx, error_code const &ec)
Fetch site whose time has come.
std::shared_ptr< Resource > startingResource
the resource to request at <timer> intervals.
boost::system::error_code error_code
bool missingSite(std::lock_guard< std::mutex > const &)
If no sites are provided, or a site fails to load, get a list of local cache files from the Validator...
bool load(std::vector< std::string > const &siteURIs)
Load configured site URIs.
endpoint_type lastRequestEndpoint