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#include <xrpl/basics/Log.h>
38#define SOCI_USE_BOOST
39#include <cstdint>
40#include <soci/soci.h>
41#include <string>
42#include <vector>
43
44namespace sqlite_api {
45struct sqlite3;
46}
47
48namespace ripple {
49
50class BasicConfig;
51
58{
60 explicit DBConfig(std::string const& dbPath);
61
62public:
63 DBConfig(BasicConfig const& config, std::string const& dbName);
65 connectionString() const;
66 void
67 open(soci::session& s) const;
68};
69
82void
83open(soci::session& s, BasicConfig const& config, std::string const& dbName);
84
94void
95open(
96 soci::session& s,
97 std::string const& beName,
98 std::string const& connectionString);
99
101getKBUsedAll(soci::session& s);
103getKBUsedDB(soci::session& s);
104
105void
106convert(soci::blob& from, std::vector<std::uint8_t>& to);
107void
108convert(soci::blob& from, std::string& to);
109void
110convert(std::vector<std::uint8_t> const& from, soci::blob& to);
111void
112convert(std::string const& from, soci::blob& to);
113
114class Checkpointer : public std::enable_shared_from_this<Checkpointer>
115{
116public:
117 virtual std::uintptr_t
118 id() const = 0;
119 virtual ~Checkpointer() = default;
120
121 virtual void
122 schedule() = 0;
123
124 virtual void
126};
127
138 JobQueue&,
139 Logs&);
140
141} // namespace ripple
142
143#if defined(__clang__)
144#pragma clang diagnostic pop
145#endif
146
147#endif
Holds unparsed configuration information.
Definition: BasicConfig.h:219
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:58
std::string connectionString_
Definition: SociDB.h:59
std::string connectionString() const
Definition: SociDB.cpp:86
A pool of threads to perform work.
Definition: JobQueue.h:56
Manages partitions for logging.
Definition: Log.h:49
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
std::uint32_t getKBUsedAll(soci::session &s)
Definition: SociDB.cpp:130
std::uint32_t getKBUsedDB(soci::session &s)
Definition: SociDB.cpp:139
void convert(soci::blob &from, std::vector< std::uint8_t > &to)
Definition: SociDB.cpp:154
@ 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:333