rippled
Loading...
Searching...
No Matches
SourceStrings.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or 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#include <xrpld/peerfinder/detail/SourceStrings.h>
21
22namespace ripple {
23namespace PeerFinder {
24
26{
27public:
28 SourceStringsImp(std::string const& name, Strings const& strings)
29 : m_name(name), m_strings(strings)
30 {
31 }
32
33 ~SourceStringsImp() = default;
34
35 std::string const&
36 name() override
37 {
38 return m_name;
39 }
40
41 void
42 fetch(Results& results, beast::Journal journal) override
43 {
44 results.addresses.resize(0);
46 for (int i = 0; i < m_strings.size(); ++i)
47 {
50 if (is_unspecified(ep))
52 if (!is_unspecified(ep))
53 results.addresses.push_back(ep);
54 }
55 }
56
57private:
60};
61
62//------------------------------------------------------------------------------
63
65SourceStrings::New(std::string const& name, Strings const& strings)
66{
67 return std::make_shared<SourceStringsImp>(name, strings);
68}
69
70} // namespace PeerFinder
71} // namespace ripple
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
static Endpoint from_string(std::string const &s)
Definition: IPEndpoint.cpp:49
A generic endpoint for log messages.
Definition: Journal.h:59
void fetch(Results &results, beast::Journal journal) override
std::string const & name() override
SourceStringsImp(std::string const &name, Strings const &strings)
Provides addresses from a static set of strings.
Definition: SourceStrings.h:31
static std::shared_ptr< Source > New(std::string const &name, Strings const &strings)
virtual std::string const & name()=0
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
T push_back(T... args)
T reserve(T... args)
T resize(T... args)
T size(T... args)
The results of a fetch.
Definition: Source.h:42