Files
rippled/include/xrpl/peerfinder/detail/Source.h
2026-08-04 13:46:55 +00:00

50 lines
1.2 KiB
C++

#pragma once
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/peerfinder/Types.h>
#include <boost/system/error_code.hpp>
#include <string>
namespace xrpl::peer_finder {
/**
* A static or dynamic source of peer addresses.
* These are used as fallbacks when we are bootstrapping and don't have
* a local cache, or when none of our addresses are functioning. Typically
* sources will represent things like static text in the config file, a
* separate local file with addresses, or a remote HTTPS URL that can
* be updated automatically. Another solution is to use a custom DNS server
* that hands out peer IP addresses when name lookups are performed.
*/
class Source
{
public:
/**
* The results of a fetch.
*/
struct Results
{
explicit Results() = default;
// error_code on a failure
boost::system::error_code error;
// list of fetched endpoints
IPAddresses addresses;
};
virtual ~Source() = default;
virtual std::string const&
name() = 0;
virtual void
cancel()
{
}
virtual void
fetch(Results& results, beast::Journal journal) = 0;
};
} // namespace xrpl::peer_finder