xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
peerfinder
SourceStrings.cpp
1
#include <xrpl/peerfinder/detail/SourceStrings.h>
2
3
#include <xrpl/beast/net/IPEndpoint.h>
4
#include <xrpl/beast/utility/Journal.h>
5
#include <xrpl/peerfinder/detail/Source.h>
6
7
#include <
memory
>
8
#include <
string
>
9
#include <
utility
>
10
11
namespace
xrpl::peer_finder
{
12
13
class
SourceStringsImp
:
public
SourceStrings
14
{
15
public
:
16
SourceStringsImp
(
std::string
name
,
Strings
strings)
17
:
name_
(
std
::move(
name
)),
strings_
(
std
::move(strings))
18
{
19
}
20
21
~SourceStringsImp
()
override
=
default
;
22
23
std::string
const
&
24
name
()
override
25
{
26
return
name_
;
27
}
28
29
void
30
fetch
(
Results
& results,
beast::Journal
journal)
override
31
{
32
results.
addresses
.
resize
(0);
33
results.
addresses
.
reserve
(
strings_
.size());
34
for
(
auto
const
& str :
strings_
)
35
{
36
beast::ip::Endpoint
ep(
beast::ip::Endpoint::fromString
(str));
37
if
(isUnspecified(ep))
38
ep =
beast::ip::Endpoint::fromString
(str);
39
if
(!isUnspecified(ep))
40
results.
addresses
.
push_back
(ep);
41
}
42
}
43
44
private
:
45
std::string
name_
;
46
Strings
strings_
;
47
};
48
49
//------------------------------------------------------------------------------
50
51
std::shared_ptr<Source>
52
SourceStrings::make
(
std::string
const
&
name
,
Strings
const
& strings)
53
{
54
return
std::make_shared<SourceStringsImp>
(
name
, strings);
55
}
56
57
}
// namespace xrpl::peer_finder
std::string
beast::Journal
A generic endpoint for log messages.
Definition
Journal.h:44
beast::ip::Endpoint
A version-independent IP address and port combination.
Definition
IPEndpoint.h:24
beast::ip::Endpoint::fromString
static Endpoint fromString(std::string const &s)
Definition
IPEndpoint.cpp:42
xrpl::peer_finder::SourceStringsImp::name_
std::string name_
Definition
SourceStrings.cpp:45
xrpl::peer_finder::SourceStringsImp::fetch
void fetch(Results &results, beast::Journal journal) override
Definition
SourceStrings.cpp:30
xrpl::peer_finder::SourceStringsImp::strings_
Strings strings_
Definition
SourceStrings.cpp:46
xrpl::peer_finder::SourceStringsImp::SourceStringsImp
SourceStringsImp(std::string name, Strings strings)
Definition
SourceStrings.cpp:16
xrpl::peer_finder::SourceStringsImp::~SourceStringsImp
~SourceStringsImp() override=default
xrpl::peer_finder::SourceStringsImp::name
std::string const & name() override
Definition
SourceStrings.cpp:24
xrpl::peer_finder::SourceStrings::SourceStrings
SourceStrings()=default
xrpl::peer_finder::SourceStrings::Strings
std::vector< std::string > Strings
Definition
SourceStrings.h:19
xrpl::peer_finder::SourceStrings::make
static std::shared_ptr< Source > make(std::string const &name, Strings const &strings)
Definition
SourceStrings.cpp:52
xrpl::peer_finder::Source::name
virtual std::string const & name()=0
std::make_shared
T make_shared(T... args)
memory
std
STL namespace.
xrpl::peer_finder
Definition
include/xrpl/peerfinder/Config.h:12
std::vector::push_back
T push_back(T... args)
std::vector::reserve
T reserve(T... args)
std::vector::resize
T resize(T... args)
std::shared_ptr
string
xrpl::peer_finder::Source::Results
The results of a fetch.
Definition
Source.h:28
xrpl::peer_finder::Source::Results::addresses
IPAddresses addresses
Definition
Source.h:35
utility
Generated by
1.17.0