rippled
Loading...
Searching...
No Matches
SociDB.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012-2015 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#ifndef RIPPLE_SOCIDB_H_INCLUDED
21#define RIPPLE_SOCIDB_H_INCLUDED
22
31#if defined(__clang__)
32#pragma clang diagnostic push
33#pragma clang diagnostic ignored "-Wdeprecated"
34#endif
35
36#include <xrpld/core/JobQueue.h>
37
38#include <xrpl/basics/Log.h>
39
40#define SOCI_USE_BOOST
41#include <soci/soci.h>
42
43#include <cstdint>
44#include <string>
45#include <vector>
46
47namespace sqlite_api {
48struct sqlite3;
49}
50
51namespace ripple {
52
53class BasicConfig;
54
61{
63 explicit DBConfig(std::string const& dbPath);
64
65public:
66 DBConfig(BasicConfig const& config, std::string const& dbName);
68 connectionString() const;
69 void
70 open(soci::session& s) const;
71};
72
85void
86open(soci::session& s, BasicConfig const& config, std::string const& dbName);
87
97void
98open(
99 soci::session& s,
100 std::string const& beName,
101 std::string const& connectionString);
102
104getKBUsedAll(soci::session& s);
106getKBUsedDB(soci::session& s);
107
108void
109convert(soci::blob& from, std::vector<std::uint8_t>& to);
110void
111convert(soci::blob& from, std::string& to);
112void
113convert(std::vector<std::uint8_t> const& from, soci::blob& to);
114void
115convert(std::string const& from, soci::blob& to);
116
117class Checkpointer : public std::enable_shared_from_this<Checkpointer>
118{
119public:
120 virtual std::uintptr_t
121 id() const = 0;
122 virtual ~Checkpointer() = default;
123
124 virtual void
125 schedule() = 0;
126
127 virtual void
129};
130
141 JobQueue&,
142 Logs&);
143
144} // namespace ripple
145
146#if defined(__clang__)
147#pragma clang diagnostic pop
148#endif
149
150#endif
Holds unparsed configuration information.
virtual ~Checkpointer()=default
virtual std::uintptr_t id() const =0
virtual void checkpoint()=0
virtual void schedule()=0
DBConfig is used when a client wants to delay opening a soci::session after parsing the config parame...
Definition SociDB.h:61
std::string connectionString_
Definition SociDB.h:62
std::string connectionString() const
Definition SociDB.cpp:89
A pool of threads to perform work.
Definition JobQueue.h:58
Manages partitions for logging.
Definition Log.h:52
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
std::uint32_t getKBUsedAll(soci::session &s)
Definition SociDB.cpp:133
std::uint32_t getKBUsedDB(soci::session &s)
Definition SociDB.cpp:142
void convert(soci::blob &from, std::vector< std::uint8_t > &to)
Definition SociDB.cpp:157
@ open
We haven't closed our ledger yet, but others might have.
std::shared_ptr< Checkpointer > makeCheckpointer(std::uintptr_t id, std::weak_ptr< soci::session > session, JobQueue &queue, Logs &logs)
Returns a new checkpointer which makes checkpoints of a soci database every checkpointPageCount pages...
Definition SociDB.cpp:336