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
39#define SOCI_USE_BOOST
40#include <cstdint>
41#include <soci/soci.h>
42#include <string>
43#include <vector>
44
45namespace sqlite_api {
46struct sqlite3;
47}
48
49namespace ripple {
50
51class BasicConfig;
52
59{
61 explicit DBConfig(std::string const& dbPath);
62
63public:
64 DBConfig(BasicConfig const& config, std::string const& dbName);
66 connectionString() const;
67 void
68 open(soci::session& s) const;
69};
70
83void
84open(soci::session& s, BasicConfig const& config, std::string const& dbName);
85
95void
96open(
97 soci::session& s,
98 std::string const& beName,
99 std::string const& connectionString);
100
102getKBUsedAll(soci::session& s);
104getKBUsedDB(soci::session& s);
105
106void
107convert(soci::blob& from, std::vector<std::uint8_t>& to);
108void
109convert(soci::blob& from, std::string& to);
110void
111convert(std::vector<std::uint8_t> const& from, soci::blob& to);
112void
113convert(std::string const& from, soci::blob& to);
114
115class Checkpointer : public std::enable_shared_from_this<Checkpointer>
116{
117public:
118 virtual std::uintptr_t
119 id() const = 0;
120 virtual ~Checkpointer() = default;
121
122 virtual void
123 schedule() = 0;
124
125 virtual void
127};
128
139 JobQueue&,
140 Logs&);
141
142} // namespace ripple
143
144#if defined(__clang__)
145#pragma clang diagnostic pop
146#endif
147
148#endif
Holds unparsed configuration information.
Definition: BasicConfig.h:218
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:59
std::string connectionString_
Definition: SociDB.h:60
std::string connectionString() const
Definition: SociDB.cpp:87
A pool of threads to perform work.
Definition: JobQueue.h:55
Manages partitions for logging.
Definition: Log.h:51
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:131
std::uint32_t getKBUsedDB(soci::session &s)
Definition: SociDB.cpp:140
void convert(soci::blob &from, std::vector< std::uint8_t > &to)
Definition: SociDB.cpp:155
@ 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:334