rippled
Loading...
Searching...
No Matches
StoreSqdb.h
1#ifndef XRPL_PEERFINDER_STORESQDB_H_INCLUDED
2#define XRPL_PEERFINDER_STORESQDB_H_INCLUDED
3
4#include <xrpld/app/rdb/PeerFinder.h>
5#include <xrpld/core/SociDB.h>
6#include <xrpld/peerfinder/detail/Store.h>
7
8namespace ripple {
9namespace PeerFinder {
10
12class StoreSqdb : public Store
13{
14private:
16 soci::session m_sqlDb;
17
18public:
19 enum {
20 // This determines the on-database format of the data
22 };
23
24 explicit StoreSqdb(
26 : m_journal(journal)
27 {
28 }
29
31 {
32 }
33
34 void
35 open(BasicConfig const& config)
36 {
37 init(config);
38 update();
39 }
40
41 // Loads the bootstrap cache, calling the callback for each entry
42 //
44 load(load_callback const& cb) override
45 {
46 std::size_t n(0);
47
48 readPeerFinderDB(m_sqlDb, [&](std::string const& s, int valence) {
49 beast::IP::Endpoint const endpoint(
51
52 if (!is_unspecified(endpoint))
53 {
54 cb(endpoint, valence);
55 ++n;
56 }
57 else
58 {
59 JLOG(m_journal.error())
60 << "Bad address string '" << s << "' in Bootcache table";
61 }
62 });
63
64 return n;
65 }
66
67 // Overwrites the stored bootstrap cache with the specified array.
68 //
69 void
70 save(std::vector<Entry> const& v) override
71 {
73 }
74
75 // Convert any existing entries from an older schema to the
76 // current one, if appropriate.
77 void
82
83private:
84 void
85 init(BasicConfig const& config)
86 {
88 }
89};
90
91} // namespace PeerFinder
92} // namespace ripple
93
94#endif
A version-independent IP address and port combination.
Definition IPEndpoint.h:19
static Endpoint from_string(std::string const &s)
A generic endpoint for log messages.
Definition Journal.h:41
Stream error() const
Definition Journal.h:327
static Sink & getNullSink()
Returns a Sink which does nothing.
Holds unparsed configuration information.
Database persistence for PeerFinder using SQLite.
Definition StoreSqdb.h:13
std::size_t load(load_callback const &cb) override
Definition StoreSqdb.h:44
void save(std::vector< Entry > const &v) override
Definition StoreSqdb.h:70
void open(BasicConfig const &config)
Definition StoreSqdb.h:35
void init(BasicConfig const &config)
Definition StoreSqdb.h:85
StoreSqdb(beast::Journal journal=beast::Journal{beast::Journal::getNullSink()})
Definition StoreSqdb.h:24
Abstract persistence for PeerFinder data.
Definition Store.h:9
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
void readPeerFinderDB(soci::session &session, std::function< void(std::string const &, int)> const &func)
readPeerFinderDB Reads all entries from the peer finder database and invokes the given callback for e...
void updatePeerFinderDB(soci::session &session, int currentSchemaVersion, beast::Journal j)
updatePeerFinderDB Updates the peer finder database to a new version.
void initPeerFinderDB(soci::session &session, BasicConfig const &config, beast::Journal j)
initPeerFinderDB Opens a session with the peer finder database.
Definition PeerFinder.cpp:6
void savePeerFinderDB(soci::session &session, std::vector< PeerFinder::Store::Entry > const &v)
savePeerFinderDB Saves a new entry to the peer finder database.