mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
182 lines
12 KiB
HTML
182 lines
12 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.17"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>rippled: Relational Database Interface</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">rippled
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.17 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
</div><!-- top -->
|
|
<div class="PageDoc"><div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">Relational Database Interface </div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div class="textblock"><p>The guiding principles of the Relational Database Interface are summarized below:</p>
|
|
<ul>
|
|
<li>All hard-coded SQL statements should be stored in the <a href="#source-files">files</a> under the <code>ripple/app/rdb</code> directory. With the exception of test modules, no hard-coded SQL should be added to any other file in rippled.</li>
|
|
<li>The base class <code>RelationalDatabase</code> is inherited by derived classes that each provide an interface for operating on distinct relational database systems.</li>
|
|
<li>For future use, the shard store will be used if the node store is absent.</li>
|
|
</ul>
|
|
<h1><a class="anchor" id="autotoc_md140"></a>
|
|
Overview</h1>
|
|
<p>Firstly, the interface <code>RelationalDatabase</code> is inherited by the classes <code>SQLiteDatabase</code> and <code>PostgresDatabase</code> which are used to operate the software's main data store (for storing transactions, accounts, ledgers, etc.). Secondly, the files under the <code>detail</code> directory provide supplementary functions that are used by these derived classes to access the underlying databases. Lastly, the remaining files in the interface (located at the top level of the module) are used by varied parts of the software to access any secondary relational databases.</p>
|
|
<h1><a class="anchor" id="autotoc_md141"></a>
|
|
Configuration</h1>
|
|
<p>The config section <code>[relational_db]</code> has a property named <code>backend</code> whose value designates which database implementation will be used for node or shard databases. Presently the only valid value for this property is <code>sqlite</code>:</p>
|
|
<div class="fragment"><div class="line">[relational_db]</div>
|
|
<div class="line">backend=sqlite</div>
|
|
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md142"></a>
|
|
Source Files</h1>
|
|
<p>The Relational Database Interface consists of the following directory structure (as of November 2021):</p>
|
|
<div class="fragment"><div class="line">src/ripple/app/rdb/</div>
|
|
<div class="line">├── backend</div>
|
|
<div class="line">│ ├── detail</div>
|
|
<div class="line">│ │ ├── impl</div>
|
|
<div class="line">│ │ │ ├── Node.cpp</div>
|
|
<div class="line">│ │ │ └── Shard.cpp</div>
|
|
<div class="line">│ │ ├── Node.h</div>
|
|
<div class="line">│ │ └── Shard.h</div>
|
|
<div class="line">│ ├── impl</div>
|
|
<div class="line">│ │ ├── PostgresDatabase.cpp</div>
|
|
<div class="line">│ │ └── SQLiteDatabase.cpp</div>
|
|
<div class="line">│ ├── PostgresDatabase.h</div>
|
|
<div class="line">│ └── SQLiteDatabase.h</div>
|
|
<div class="line">├── impl</div>
|
|
<div class="line">│ ├── Download.cpp</div>
|
|
<div class="line">│ ├── PeerFinder.cpp</div>
|
|
<div class="line">│ ├── RelationalDatabase.cpp</div>
|
|
<div class="line">│ ├── ShardArchive.cpp</div>
|
|
<div class="line">│ ├── State.cpp</div>
|
|
<div class="line">│ ├── UnitaryShard.cpp</div>
|
|
<div class="line">│ ├── Vacuum.cpp</div>
|
|
<div class="line">│ └── Wallet.cpp</div>
|
|
<div class="line">├── Download.h</div>
|
|
<div class="line">├── PeerFinder.h</div>
|
|
<div class="line">├── RelationalDatabase.h</div>
|
|
<div class="line">├── README.md</div>
|
|
<div class="line">├── ShardArchive.h</div>
|
|
<div class="line">├── State.h</div>
|
|
<div class="line">├── UnitaryShard.h</div>
|
|
<div class="line">├── Vacuum.h</div>
|
|
<div class="line">└── Wallet.h</div>
|
|
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md143"></a>
|
|
File Contents</h2>
|
|
<table class="markdownTable">
|
|
<tr class="markdownTableHead">
|
|
<th class="markdownTableHeadNone">File </th><th class="markdownTableHeadNone">Contents </th></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone"><code>Node.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements methods used by <code>SQLiteDatabase</code> for interacting with SQLite node databases </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone"><code>Shard.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements methods used by <code>SQLiteDatabase</code> for interacting with SQLite shard databases </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone"><nobr><code>PostgresDatabase.[h\|cpp]</code></nobr> </td><td class="markdownTableBodyNone">Defines/Implements the class <code>PostgresDatabase</code>/<code>PostgresDatabaseImp</code> which inherits from <code>RelationalDatabase</code> and is used to operate on the main stores </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone"><code>SQLiteDatabase.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements the class <code>SQLiteDatabase</code>/<code>SQLiteDatabaseImp</code> which inherits from <code>RelationalDatabase</code> and is used to operate on the main stores </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone"><code>Download.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements methods for persisting file downloads to a SQLite database </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone"><code>PeerFinder.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements methods for interacting with the PeerFinder SQLite database </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone"><code><a class="el" href="RelationalDatabase_8cpp_source.html">RelationalDatabase.cpp</a></code> </td><td class="markdownTableBodyNone">Implements the static method <code>RelationalDatabase::init</code> which is used to initialize an instance of <code>RelationalDatabase</code> </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone"><code><a class="el" href="RelationalDatabase_8h_source.html">RelationalDatabase.h</a></code> </td><td class="markdownTableBodyNone">Defines the abstract class <code>RelationalDatabase</code>, the primary class of the Relational Database Interface </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone"><code>ShardArchive.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements methods used by <code>ShardArchiveHandler</code> for interacting with SQLite databases containing metadata regarding shard downloads </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone"><code>State.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements methods for interacting with the State SQLite database which concerns ledger deletion and database rotation </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone"><code>UnitaryShard.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements methods used by a unitary instance of <code>Shard</code> for interacting with the various SQLite databases thereof. These files are distinct from <code>Shard.[h\|cpp]</code> which contain methods used by <code>SQLiteDatabaseImp</code> </td></tr>
|
|
<tr class="markdownTableRowEven">
|
|
<td class="markdownTableBodyNone"><code>Vacuum.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements a method for performing the <code>VACUUM</code> operation on SQLite databases </td></tr>
|
|
<tr class="markdownTableRowOdd">
|
|
<td class="markdownTableBodyNone"><code>Wallet.[h\|cpp]</code> </td><td class="markdownTableBodyNone">Defines/Implements methods for interacting with Wallet SQLite databases </td></tr>
|
|
</table>
|
|
<h1><a class="anchor" id="autotoc_md144"></a>
|
|
Classes</h1>
|
|
<p>The abstract class <code>RelationalDatabase</code> is the primary class of the Relational Database Interface and is defined in the eponymous header file. This class provides a static method <code>init()</code> which, when invoked, creates a concrete instance of a derived class whose type is specified by the system configuration. All other methods in the class are virtual. Presently there exist two classes that derive from <code>RelationalDatabase</code>, namely <code>SQLiteDatabase</code> and <code>PostgresDatabase</code>.</p>
|
|
<h1><a class="anchor" id="autotoc_md145"></a>
|
|
Database Methods</h1>
|
|
<p>The Relational Database Interface provides three categories of methods for interacting with databases:</p>
|
|
<ul>
|
|
<li>Free functions for interacting with SQLite databases used by various components of the software. These methods feature a <code>soci::session</code> parameter which facilitates connecting to SQLite databases, and are defined and implemented in the following files:<ul>
|
|
<li><code>Download.[h\|cpp]</code></li>
|
|
<li><code>PeerFinder.[h\|cpp]</code></li>
|
|
<li><code>ShardArchive.[h\|cpp]</code></li>
|
|
<li><code>State.[h\|cpp]</code></li>
|
|
<li><code>UnitaryShard.[h\|cpp]</code></li>
|
|
<li><code>Vacuum.[h\|cpp]</code></li>
|
|
<li><code>Wallet.[h\|cpp]</code></li>
|
|
</ul>
|
|
</li>
|
|
<li>Free functions used exclusively by <code>SQLiteDatabaseImp</code> for interacting with SQLite databases owned by the node store or shard store. Unlike the free functions in the files listed above, these are not intended to be invoked directly by clients. Rather, these methods are invoked by derived instances of <code>RelationalDatabase</code>. These methods are defined in the following files:<ul>
|
|
<li><code>Node.[h|cpp]</code></li>
|
|
<li><code>Shard.[h|cpp]</code></li>
|
|
</ul>
|
|
</li>
|
|
<li>Member functions of <code>RelationalDatabase</code>, <code>SQLiteDatabase</code>, and <code>PostgresDatabase</code> which are used to access the main stores (node store, shard store). The <code>SQLiteDatabase</code> class will access the node store by default, but will use shard databases if the node store is not present and the shard store is available. The class <code>PostgresDatabase</code> uses only the node store. </li>
|
|
</ul>
|
|
</div></div><!-- contents -->
|
|
</div><!-- PageDoc -->
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.17
|
|
</small></address>
|
|
</body>
|
|
</html>
|