rippled
Loading...
Searching...
No Matches
StoreSqdb.h
1#pragma once
2
3#include <xrpld/app/rdb/PeerFinder.h>
4#include <xrpld/peerfinder/detail/Store.h>
5
6#include <xrpl/rdb/SociDB.h>
7
8namespace xrpl {
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
27
29 {
30 }
31
32 void
33 open(BasicConfig const& config)
34 {
35 init(config);
36 update();
37 }
38
39 // Loads the bootstrap cache, calling the callback for each entry
40 //
42 load(load_callback const& cb) override
43 {
44 std::size_t n(0);
45
46 readPeerFinderDB(m_sqlDb, [&](std::string const& s, int valence) {
48
49 if (!is_unspecified(endpoint))
50 {
51 cb(endpoint, valence);
52 ++n;
53 }
54 else
55 {
56 JLOG(m_journal.error()) << "Bad address string '" << s << "' in Bootcache table";
57 }
58 });
59
60 return n;
61 }
62
63 // Overwrites the stored bootstrap cache with the specified array.
64 //
65 void
66 save(std::vector<Entry> const& v) override
67 {
69 }
70
71 // Convert any existing entries from an older schema to the
72 // current one, if appropriate.
73 void
78
79private:
80 void
81 init(BasicConfig const& config)
82 {
84 }
85};
86
87} // namespace PeerFinder
88} // namespace xrpl
A version-independent IP address and port combination.
Definition IPEndpoint.h:18
static Endpoint from_string(std::string const &s)
A generic endpoint for log messages.
Definition Journal.h:40
Stream error() const
Definition Journal.h:318
static Sink & getNullSink()
Returns a Sink which does nothing.
Holds unparsed configuration information.
Database persistence for PeerFinder using SQLite.
Definition StoreSqdb.h:13
beast::Journal m_journal
Definition StoreSqdb.h:15
void open(BasicConfig const &config)
Definition StoreSqdb.h:33
std::size_t load(load_callback const &cb) override
Definition StoreSqdb.h:42
void init(BasicConfig const &config)
Definition StoreSqdb.h:81
StoreSqdb(beast::Journal journal=beast::Journal{beast::Journal::getNullSink()})
Definition StoreSqdb.h:24
void save(std::vector< Entry > const &v) override
Definition StoreSqdb.h:66
Abstract persistence for PeerFinder data.
Definition Store.h:8
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
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.