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
25 : m_journal(journal)
26 {
27 }
28
30 {
31 }
32
33 void
34 open(BasicConfig const& config)
35 {
36 init(config);
37 update();
38 }
39
40 // Loads the bootstrap cache, calling the callback for each entry
41 //
43 load(load_callback const& cb) override
44 {
45 std::size_t n(0);
46
47 readPeerFinderDB(m_sqlDb, [&](std::string const& s, int valence) {
49
50 if (!is_unspecified(endpoint))
51 {
52 cb(endpoint, valence);
53 ++n;
54 }
55 else
56 {
57 JLOG(m_journal.error()) << "Bad address string '" << s << "' in Bootcache table";
58 }
59 });
60
61 return n;
62 }
63
64 // Overwrites the stored bootstrap cache with the specified array.
65 //
66 void
67 save(std::vector<Entry> const& v) override
68 {
70 }
71
72 // Convert any existing entries from an older schema to the
73 // current one, if appropriate.
74 void
79
80private:
81 void
82 init(BasicConfig const& config)
83 {
85 }
86};
87
88} // namespace PeerFinder
89} // 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:319
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:34
std::size_t load(load_callback const &cb) override
Definition StoreSqdb.h:43
void init(BasicConfig const &config)
Definition StoreSqdb.h:82
StoreSqdb(beast::Journal journal=beast::Journal{beast::Journal::getNullSink()})
Definition StoreSqdb.h:24
void save(std::vector< Entry > const &v) override
Definition StoreSqdb.h:67
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.