Use soci in some places:

* Brings the soci subtree into rippled.
* Validator, peerfinder, and SHAMapStore use new soci backend.
* Optional postgresql backend for soci (if POSTGRESQL_ROOT env var is set).
This commit is contained in:
seelabs
2015-01-22 15:04:30 -08:00
committed by Vinnie Falco
parent c7cfd23580
commit d0ef2f7dd8
28 changed files with 1412 additions and 663 deletions

View File

@@ -795,85 +795,6 @@
</ClCompile>
<ClInclude Include="..\..\src\beast\beast\module\core\time\Time.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\backend.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\blob.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\into.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\session.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\statement.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\transaction.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\type_conversion_traits.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\use.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\error_codes.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\exchange_traits.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\into_type.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\once_temp_type.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\prepare_temp_type.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\ref_counted_prepare_info.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\ref_counted_statement.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\statement_imp.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\type_conversion.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\type_ptr.h">
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\use_type.h">
</ClInclude>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\blob.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\error_codes.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\into_type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\once_temp_type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\prepare_temp_type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\ref_counted_prepare_info.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\ref_counted_statement.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\session.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\statement.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\statement_imp.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\transaction.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\use_type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\sqdb.h">
</ClInclude>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\sqdb.unity.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\beast\beast\module\sqlite\sqlite.h">
</ClInclude>
<ClCompile Include="..\..\src\beast\beast\module\sqlite\sqlite.unity.c">
@@ -1535,6 +1456,20 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\data\DBInit.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\data\DummySociDynamicBackend.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='debug.classic|x64'">..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='release.classic|x64'">..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\data\SociDB.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='debug.classic|x64'">..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='release.classic|x64'">..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\data\SociDB.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\data\SqliteDatabase.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
@@ -1543,6 +1478,12 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\data\SqliteDatabase.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\data\tests\SociDB.test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='debug.classic|x64'">..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='release.classic|x64'">..\..\src\soci\src\core;..\..\src\sqlite;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\impl\BasicApp.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
@@ -4382,8 +4323,182 @@
</ClCompile>
<ClInclude Include="..\..\src\snappy\snappy\snappy.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\backends\postgresql\soci-postgresql.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\blob.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\common.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\backends\sqlite3\common.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\factory.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\row-id.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\session.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\backends\sqlite3\soci-sqlite3.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\standard-into-type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\standard-use-type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\statement.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\vector-into-type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\vector-use-type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\backend-loader.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\blob-exchange.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\blob.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\blob.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\boost-fusion.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\boost-gregorian-date.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\boost-optional.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\boost-tuple.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\connection-parameters.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\connection-parameters.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\connection-pool.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\connection-pool.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\error.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\error.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\exchange-traits.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\into-type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\into-type.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\into.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\once-temp-type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\once-temp-type.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\prepare-temp-type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\prepare-temp-type.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\procedure.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\procedure.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\query_transformation.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\ref-counted-prepare-info.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\ref-counted-prepare-info.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\ref-counted-statement.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\ref-counted-statement.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\row-exchange.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\row.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\row.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\rowid-exchange.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\rowid.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\rowid.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\rowset.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\session.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\session.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\soci-backend.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\soci-config.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\soci-platform.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\soci-simple.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\soci-simple.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\soci.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\statement.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\statement.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\transaction.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\transaction.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\type-conversion-traits.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\type-conversion.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\type-holder.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\type-ptr.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\unsigned-types.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\use-type.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\use-type.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\use.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\values-exchange.h">
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\values.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\values.h">
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\version.h">
</ClInclude>
<ClInclude Include="..\..\src\sqlite\sqlite3.h">
</ClInclude>
<ClInclude Include="..\..\src\websocketpp\websocketpp\base64\base64.hpp">
</ClInclude>
<ClInclude Include="..\..\src\websocketpp\websocketpp\close.hpp">

View File

@@ -139,18 +139,6 @@
<Filter Include="beast\module\core\time">
<UniqueIdentifier>{FEAEA931-9FBB-1723-2676-9115C88A7A91}</UniqueIdentifier>
</Filter>
<Filter Include="beast\module\sqdb">
<UniqueIdentifier>{C0E15D88-0464-5647-4456-2B7D1D035D96}</UniqueIdentifier>
</Filter>
<Filter Include="beast\module\sqdb\api">
<UniqueIdentifier>{9D06F3E0-B69D-2375-0CDB-EFADCCB10AA7}</UniqueIdentifier>
</Filter>
<Filter Include="beast\module\sqdb\detail">
<UniqueIdentifier>{4A5C6976-0040-11F9-2847-EF7966479B6D}</UniqueIdentifier>
</Filter>
<Filter Include="beast\module\sqdb\source">
<UniqueIdentifier>{DE6FE26E-81A4-F99F-CCA4-6E59C53026D1}</UniqueIdentifier>
</Filter>
<Filter Include="beast\module\sqlite">
<UniqueIdentifier>{81C8331F-4768-BDE6-D058-29BDEE8F322C}</UniqueIdentifier>
</Filter>
@@ -280,6 +268,9 @@
<Filter Include="ripple\app\data">
<UniqueIdentifier>{44B63F90-BC60-A7C7-24A1-632A358E285B}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\app\data\tests">
<UniqueIdentifier>{29C76FB9-636F-FBFC-3CFA-2979281BC279}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\app\impl">
<UniqueIdentifier>{17F94278-7CDE-3EBE-7CD3-372F08902314}</UniqueIdentifier>
</Filter>
@@ -550,9 +541,21 @@
<Filter Include="soci\src">
<UniqueIdentifier>{5A1D8022-39F2-67E1-FFBE-EA7D5BF9FBDB}</UniqueIdentifier>
</Filter>
<Filter Include="soci\src\backends">
<UniqueIdentifier>{AA927DBA-1AF8-6600-04B7-D1C1EBFB4103}</UniqueIdentifier>
</Filter>
<Filter Include="soci\src\backends\postgresql">
<UniqueIdentifier>{5D2927A9-CC6E-DDE0-1654-5316177082DD}</UniqueIdentifier>
</Filter>
<Filter Include="soci\src\backends\sqlite3">
<UniqueIdentifier>{75E6832F-A6F7-8360-FA3A-7427A06A9959}</UniqueIdentifier>
</Filter>
<Filter Include="soci\src\core">
<UniqueIdentifier>{D4BF99B9-6486-2124-6103-825710EDD595}</UniqueIdentifier>
</Filter>
<Filter Include="sqlite">
<UniqueIdentifier>{FA8496D0-0D5F-AC6F-3422-DEAB4BA19ACA}</UniqueIdentifier>
</Filter>
<Filter Include="websocketpp">
<UniqueIdentifier>{EE7AC8C9-27EB-C05E-C986-EECB0174B997}</UniqueIdentifier>
</Filter>
@@ -1377,105 +1380,6 @@
<ClInclude Include="..\..\src\beast\beast\module\core\time\Time.h">
<Filter>beast\module\core\time</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\backend.h">
<Filter>beast\module\sqdb\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\blob.h">
<Filter>beast\module\sqdb\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\into.h">
<Filter>beast\module\sqdb\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\session.h">
<Filter>beast\module\sqdb\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\statement.h">
<Filter>beast\module\sqdb\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\transaction.h">
<Filter>beast\module\sqdb\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\type_conversion_traits.h">
<Filter>beast\module\sqdb\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\api\use.h">
<Filter>beast\module\sqdb\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\error_codes.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\exchange_traits.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\into_type.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\once_temp_type.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\prepare_temp_type.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\ref_counted_prepare_info.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\ref_counted_statement.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\statement_imp.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\type_conversion.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\type_ptr.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\detail\use_type.h">
<Filter>beast\module\sqdb\detail</Filter>
</ClInclude>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\blob.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\error_codes.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\into_type.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\once_temp_type.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\prepare_temp_type.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\ref_counted_prepare_info.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\ref_counted_statement.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\session.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\statement.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\statement_imp.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\transaction.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\source\use_type.cpp">
<Filter>beast\module\sqdb\source</Filter>
</ClCompile>
<ClInclude Include="..\..\src\beast\beast\module\sqdb\sqdb.h">
<Filter>beast\module\sqdb</Filter>
</ClInclude>
<ClCompile Include="..\..\src\beast\beast\module\sqdb\sqdb.unity.cpp">
<Filter>beast\module\sqdb</Filter>
</ClCompile>
<ClInclude Include="..\..\src\beast\beast\module\sqlite\sqlite.h">
<Filter>beast\module\sqlite</Filter>
</ClInclude>
@@ -2286,12 +2190,24 @@
<ClInclude Include="..\..\src\ripple\app\data\DBInit.h">
<Filter>ripple\app\data</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\data\DummySociDynamicBackend.cpp">
<Filter>ripple\app\data</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\data\SociDB.cpp">
<Filter>ripple\app\data</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\data\SociDB.h">
<Filter>ripple\app\data</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\data\SqliteDatabase.cpp">
<Filter>ripple\app\data</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\data\SqliteDatabase.h">
<Filter>ripple\app\data</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\data\tests\SociDB.test.cpp">
<Filter>ripple\app\data\tests</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\app\impl\BasicApp.cpp">
<Filter>ripple\app\impl</Filter>
</ClCompile>
@@ -5148,9 +5064,228 @@
<ClInclude Include="..\..\src\snappy\snappy\snappy.h">
<Filter>snappy\snappy</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\backends\postgresql\soci-postgresql.h">
<Filter>soci\src\backends\postgresql</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\blob.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\common.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\backends\sqlite3\common.h">
<Filter>soci\src\backends\sqlite3</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\factory.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\row-id.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\session.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\backends\sqlite3\soci-sqlite3.h">
<Filter>soci\src\backends\sqlite3</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\standard-into-type.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\standard-use-type.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\statement.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\vector-into-type.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClCompile Include="..\..\src\soci\src\backends\sqlite3\vector-use-type.cpp">
<Filter>soci\src\backends\sqlite3</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\backend-loader.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\blob-exchange.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\blob.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\blob.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\boost-fusion.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\boost-gregorian-date.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\boost-optional.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\boost-tuple.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\connection-parameters.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\connection-parameters.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\connection-pool.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\connection-pool.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\error.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\error.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\exchange-traits.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\into-type.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\into-type.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\into.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\once-temp-type.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\once-temp-type.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\prepare-temp-type.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\prepare-temp-type.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\procedure.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\procedure.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\query_transformation.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\ref-counted-prepare-info.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\ref-counted-prepare-info.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\ref-counted-statement.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\ref-counted-statement.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\row-exchange.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\row.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\row.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\rowid-exchange.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\rowid.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\rowid.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\rowset.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\session.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\session.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\soci-backend.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\soci-config.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\soci-platform.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\soci-simple.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\soci-simple.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\soci.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\statement.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\statement.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\transaction.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\transaction.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\type-conversion-traits.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\type-conversion.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\type-holder.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\type-ptr.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\unsigned-types.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\use-type.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\use-type.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\use.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\values-exchange.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClCompile Include="..\..\src\soci\src\core\values.cpp">
<Filter>soci\src\core</Filter>
</ClCompile>
<ClInclude Include="..\..\src\soci\src\core\values.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\soci\src\core\version.h">
<Filter>soci\src\core</Filter>
</ClInclude>
<ClInclude Include="..\..\src\sqlite\sqlite3.h">
<Filter>sqlite</Filter>
</ClInclude>
<ClInclude Include="..\..\src\websocketpp\websocketpp\base64\base64.hpp">
<Filter>websocketpp\websocketpp\base64</Filter>
</ClInclude>

View File

@@ -0,0 +1,59 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012-2015 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
/** Stub functions for soci dynamic backends.
Ripple does not use dynamic backends, and inclduing soci's
dynamic backends compilcates the build (it requires a generated
header file and some macros to be defines.)
*/
#include <BeastConfig.h>
#include <ripple/app/data/SociDB.h>
// dummy soci-backend
namespace soci {
namespace dynamic_backends {
// used internally by session
backend_factory const& get (std::string const& name)
{
throw std::runtime_error ("Not Supported");
backend_factory* nullBF{nullptr};
return *nullBF; // deref nullptr - but we already threw
};
// provided for advanced user-level management
std::vector<std::string>& search_paths ()
{
static std::vector<std::string> empty;
return empty;
};
void register_backend (std::string const&, std::string const&){};
void register_backend (std::string const&, backend_factory const&){};
std::vector<std::string> list_all ()
{
return {};
};
void unload (std::string const&){};
void unload_all (){};
} // namespace dynamic_backends
} // namespace soci

View File

@@ -0,0 +1,173 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012-2015 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
/** An embedded database wrapper with an intuitive, type-safe interface.
This collection of classes let's you access embedded SQLite databases
using C++ syntax that is very similar to regular SQL.
This module requires the @ref beast_sqlite external module.
*/
#include <BeastConfig.h>
#include <ripple/core/ConfigSections.h>
#include <ripple/app/data/SociDB.h>
#include <ripple/core/Config.h>
#include <beast/cxx14/memory.h> // <memory>
#include <backends/sqlite3/soci-sqlite3.h>
#if ENABLE_SOCI_POSTGRESQL
#include <backends/postgresql/soci-postgresql.h>
#endif
#include <boost/filesystem.hpp>
namespace ripple {
namespace detail {
std::pair<std::string, soci::backend_factory const&>
getSociSqliteInit (std::string const& name,
std::string const& dir,
std::string const& ext)
{
if (dir.empty () || name.empty ())
{
throw std::runtime_error (
"Sqlite databases must specify a dir and a name. Name: " +
name + " Dir: " + dir);
}
boost::filesystem::path file (dir);
if (is_directory (file))
file /= name + ext;
return std::make_pair (file.string (), std::ref(soci::sqlite3));
}
#if ENABLE_SOCI_POSTGRESQL
std::pair<std::string, soci::backend_factory const&>
getSociPostgresqlInit (Section const& configSection,
std::string const& name)
{
if (name.empty ())
{
throw std::runtime_error (
"Missing required value for postgresql backend: database name");
}
std::string const host(get <std::string> (configSection, "host", ""));
if (!host.empty())
{
throw std::runtime_error (
"Missing required value in config for postgresql backend: host");
}
std::string const user(get <std::string> (configSection, "user", ""));
if (user.empty ())
{
throw std::runtime_error (
"Missing required value in config for postgresql backend: user");
}
int const port = [&configSection]
{
std::string const portAsString (
get <std::string> (configSection, "port", ""));
if (portAsString.empty ())
{
throw std::runtime_error (
"Missing required value in config for postgresql backend: "
"user");
}
try
{
return std::stoi (portAsString);
}
catch (...)
{
throw std::runtime_error (
"The port value in the config for the postgresql backend must "
"be an integer. Got: " +
portAsString);
}
}();
std::stringstream s;
s << "host=" << host << " port=" << port << " dbname=" << name
<< " user=" << user;
return std::make_pair (s.str (), std::ref(soci::postgresql));
}
#endif // ENABLE_SOCI_POSTGRESQL
std::pair<std::string, soci::backend_factory const&>
getSociInit (BasicConfig const& config,
std::string const& dbName)
{
static const std::string sectionName ("sqdb");
static const std::string keyName ("backend");
auto const& section = config.section (sectionName);
std::string const backendName(get(section, keyName, std::string("sqlite")));
if (backendName == "sqlite")
{
std::string const path = config.legacy ("database_path");
std::string const ext =
(dbName == "validators" || dbName == "peerfinder") ? ".sqlite"
: ".db";
return detail::getSociSqliteInit(dbName, path, ext);
}
#if ENABLE_SOCI_POSTGRESQL
else if (backendName == "postgresql")
{
return detail::getSociPostgresqlInit(section, dbName);
}
#endif
else
{
throw std::runtime_error ("Unsupported soci backend: " + backendName);
}
}
} // detail
SociConfig::SociConfig(std::pair<std::string, soci::backend_factory const&> init)
:connectionString_(std::move(init.first)),
backendFactory_(init.second){}
SociConfig::SociConfig(BasicConfig const& config,
std::string const& dbName)
: SociConfig(detail::getSociInit(config, dbName))
{
}
std::string SociConfig::connectionString () const
{
return connectionString_;
}
void SociConfig::open(soci::session& s) const
{
s.open (backendFactory_, connectionString ());
}
void open(soci::session& s,
BasicConfig const& config,
std::string const& dbName)
{
SociConfig c(config, dbName);
c.open(s);
}
}

View File

@@ -0,0 +1,79 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012-2015 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_SOCIDB_H_INCLUDED
#define RIPPLE_SOCIDB_H_INCLUDED
/** An embedded database wrapper with an intuitive, type-safe interface.
This collection of classes let's you access embedded SQLite databases
using C++ syntax that is very similar to regular SQL.
This module requires the @ref beast_sqlite external module.
*/
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning( \
disable : 4355) // 'this' : used in base member initializer list
#endif
#include <core/soci.h>
namespace ripple {
class BasicConfig;
/**
* SociConfig is used when a client wants to delay opening a soci::session after
* parsing the config parameters. If a client want to open a session immediately,
* use the free function "open" below.
*/
class SociConfig final
{
std::string connectionString_;
soci::backend_factory const& backendFactory_;
SociConfig(std::pair<std::string, soci::backend_factory const&> init);
public:
SociConfig(BasicConfig const& config,
std::string const& dbName);
std::string connectionString () const;
void open(soci::session& s) const;
};
/**
* Open a soci session.
*
* @param s Session to open.
* @param config Parameters to pick the soci backend and how to connect to that
* backend.
* @param dbName Name of the database. This has different meaning for different backends.
* Sometimes it is part of a filename (sqlite3), othertimes it is a
* database name (postgresql).
*/
void open(soci::session& s,
BasicConfig const& config,
std::string const& dbName);
}
#if _MSC_VER
#pragma warning(pop)
#endif
#endif

View File

@@ -0,0 +1,197 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012-2015 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <BeastConfig.h>
#include <ripple/app/data/SociDB.h>
#include <ripple/core/ConfigSections.h>
#include <ripple/basics/TestSuite.h>
#include <ripple/basics/BasicConfig.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
namespace ripple {
class SociDB_test final : public TestSuite
{
private:
static void setupSQLiteConfig (BasicConfig& config,
boost::filesystem::path const& dbPath)
{
config.overwrite ("sqdb", "backend", "sqlite");
auto value = dbPath.string ();
if (!value.empty ())
config.legacy ("database_path", value);
}
static void setupPostgresqlConfig (BasicConfig& config,
std::string const& host,
std::string const& user,
std::string const& port)
{
config.overwrite ("sqdb", "backend", "postgresql");
if (!host.empty ())
config.overwrite ("sqdb", "host", host);
if (!user.empty ())
config.overwrite ("sqdb", "user", user);
if (!port.empty ())
config.overwrite ("sqdb", "port", port);
}
static void cleanupDatabaseDir (boost::filesystem::path const& dbPath)
{
using namespace boost::filesystem;
if (!exists (dbPath) || !is_directory (dbPath) || !is_empty (dbPath))
return;
remove (dbPath);
}
static void setupDatabaseDir (boost::filesystem::path const& dbPath)
{
using namespace boost::filesystem;
if (!exists (dbPath))
{
create_directory (dbPath);
return;
}
if (!is_directory (dbPath))
{
// someone created a file where we want to put out directory
throw std::runtime_error ("Cannot create directory: " +
dbPath.string ());
}
}
static boost::filesystem::path getDatabasePath ()
{
return boost::filesystem::current_path () / "socidb_test_databases";
}
public:
SociDB_test ()
{
try
{
setupDatabaseDir (getDatabasePath ());
}
catch (...)
{
}
}
~SociDB_test ()
{
try
{
cleanupDatabaseDir (getDatabasePath ());
}
catch (...)
{
}
}
void testSQLiteFileNames ()
{
// confirm that files are given the correct exensions
testcase ("sqliteFileNames");
BasicConfig c;
setupSQLiteConfig (c, getDatabasePath ());
std::vector<std::pair<const char*, const char*>> const d (
{{"peerfinder", ".sqlite"},
{"state", ".db"},
{"random", ".db"},
{"validators", ".sqlite"}});
for (auto const& i : d)
{
SociConfig sc (c, i.first);
expect (boost::ends_with (sc.connectionString (),
std::string (i.first) + i.second));
}
}
void testSQLiteSession ()
{
testcase ("open");
BasicConfig c;
setupSQLiteConfig (c, getDatabasePath ());
SociConfig sc (c, "SociTestDB");
std::vector<std::string> const stringData (
{"String1", "String2", "String3"});
std::vector<int> const intData ({1, 2, 3});
auto checkValues = [this, &stringData, &intData](soci::session& s)
{
// Check values in db
std::vector<std::string> stringResult (20 * stringData.size ());
std::vector<int> intResult (20 * intData.size ());
s << "SELECT StringData, IntData FROM SociTestTable",
soci::into (stringResult), soci::into (intResult);
expect (stringResult.size () == stringData.size () &&
intResult.size () == intData.size ());
for (int i = 0; i < stringResult.size (); ++i)
{
auto si = std::distance (stringData.begin (),
std::find (stringData.begin (),
stringData.end (),
stringResult[i]));
auto ii = std::distance (
intData.begin (),
std::find (intData.begin (), intData.end (), intResult[i]));
expect (si == ii && si < stringResult.size ());
}
};
{
soci::session s;
sc.open (s);
s << "CREATE TABLE IF NOT EXISTS SociTestTable ("
" Key INTEGER PRIMARY KEY,"
" StringData TEXT,"
" IntData INTEGER"
");";
s << "INSERT INTO SociTestTable (StringData, IntData) VALUES "
"(:stringData, :intData);",
soci::use (stringData), soci::use (intData);
checkValues (s);
}
{
// Check values in db after session was closed
soci::session s;
sc.open (s);
checkValues (s);
}
{
using namespace boost::filesystem;
// Remove the database
path dbPath (sc.connectionString ());
if (is_regular_file (dbPath))
remove (dbPath);
}
}
void testSQLite ()
{
testSQLiteFileNames ();
testSQLiteSession ();
}
void run ()
{
testSQLite ();
}
};
BEAST_DEFINE_TESTSUITE (SociDB, app, ripple);
} // ripple

View File

@@ -329,7 +329,7 @@ public:
, m_shaMapStore (make_SHAMapStore (setup_SHAMapStore (
getConfig()), *this, m_nodeStoreScheduler,
m_logs.journal ("SHAMapStore"), m_logs.journal ("NodeObject"),
m_txMaster))
m_txMaster, getConfig()))
, m_nodeStore (m_shaMapStore->makeDatabase ("NodeStore.main", 4))
@@ -394,7 +394,7 @@ public:
, m_sntpClient (SNTPClient::New (*this))
, m_validators (Validators::make_Manager(*this, get_io_service(),
getConfig ().getModuleDatabasePath (), m_logs.journal("UVL")))
m_logs.journal("UVL"), getConfig ()))
, m_amendmentTable (make_AmendmentTable
(weeks(2), MAJORITY_FRACTION,
@@ -797,9 +797,8 @@ public:
//
// if (!getConfig ().RUN_STANDALONE)
m_overlay = make_Overlay (setup_Overlay(getConfig()), *m_jobQueue,
*serverHandler_, *m_resourceManager,
getConfig ().getModuleDatabasePath (), *m_resolver,
get_io_service());
*serverHandler_, *m_resourceManager, *m_resolver, get_io_service(),
getConfig());
add (*m_overlay); // add to PropertyStream
{

View File

@@ -161,13 +161,14 @@ void printHelp (const po::options_description& desc)
static
void
setupConfigForUnitTests (Config* config)
setupConfigForUnitTests (Config& config)
{
config->overwrite (ConfigSection::nodeDatabase (), "type", "memory");
config->overwrite (ConfigSection::nodeDatabase (), "path", "main");
config->deprecatedClearSection (ConfigSection::tempNodeDatabase ());
config->deprecatedClearSection (ConfigSection::importNodeDatabase ());
config.legacy("database_path", "DummyForUnitTests");
}
static int runShutdownTests ()
@@ -201,7 +202,7 @@ static int runUnitTests (std::string const& pattern,
std::string const& argument)
{
// Config needs to be set up before creating Application
setupConfigForUnitTests (&getConfig ());
setupConfigForUnitTests (getConfig ());
// VFALCO TODO Remove dependence on constructing Application object
std::unique_ptr <Application> app (make_Application (deprecatedLogs()));
using namespace beast::unit_test;

View File

@@ -85,7 +85,8 @@ make_SHAMapStore(SHAMapStore::Setup const& s,
NodeStore::Scheduler& scheduler,
beast::Journal journal,
beast::Journal nodeStoreJournal,
TransactionMaster& transactionMaster);
TransactionMaster& transactionMaster,
BasicConfig const& conf);
}
#endif

View File

@@ -18,31 +18,26 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/app/misc/SHAMapStoreImp.h>
#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/app/main/Application.h>
#include <ripple/core/ConfigSections.h>
#include <boost/format.hpp>
#include <beast/cxx14/memory.h> // <memory>
#include <boost/format.hpp>
namespace ripple {
void
SHAMapStoreImp::SavedStateDB::init (std::string const& databasePath,
void SHAMapStoreImp::SavedStateDB::init (BasicConfig const& config,
std::string const& dbName)
{
boost::filesystem::path pathName = databasePath;
pathName /= dbName;
std::lock_guard<std::mutex> lock (mutex_);
std::lock_guard <std::mutex> lock (mutex_);
open(session_, config, dbName);
auto error = session_.open (pathName.string());
checkError (error);
session_ << "PRAGMA synchronous=FULL;";
session_.once (error) << "PRAGMA synchronous=FULL;";
checkError (error);
session_.once (error) <<
session_ <<
"CREATE TABLE IF NOT EXISTS DbState ("
" Key INTEGER PRIMARY KEY,"
" WritableDb TEXT,"
@@ -50,9 +45,8 @@ SHAMapStoreImp::SavedStateDB::init (std::string const& databasePath,
" LastRotatedLedger INTEGER"
");"
;
checkError (error);
session_.once (error) <<
session_ <<
"CREATE TABLE IF NOT EXISTS CanDelete ("
" Key INTEGER PRIMARY KEY,"
" CanDeleteSeq INTEGER"
@@ -60,50 +54,49 @@ SHAMapStoreImp::SavedStateDB::init (std::string const& databasePath,
;
std::int64_t count = 0;
beast::sqdb::statement st = (session_.prepare <<
soci::statement st = (session_.prepare <<
"SELECT COUNT(Key) FROM DbState WHERE Key = 1;"
, beast::sqdb::into (count)
, soci::into (count)
);
st.execute_and_fetch (error);
checkError (error);
st.execute ();
if (!st.fetch ())
{
throw std::runtime_error("Failed to fetch Key Count from DbState.");
}
if (!count)
{
session_.once (error) <<
session_ <<
"INSERT INTO DbState VALUES (1, '', '', 0);";
checkError (error);
}
st = (session_.prepare <<
"SELECT COUNT(Key) FROM CanDelete WHERE Key = 1;"
, beast::sqdb::into (count)
, soci::into (count)
);
st.execute_and_fetch (error);
checkError (error);
st.execute ();
if (!st.fetch ())
{
throw std::runtime_error ("Failed to fetch Key Count from CanDelete.");
}
if (!count)
{
session_.once (error) <<
session_ <<
"INSERT INTO CanDelete VALUES (1, 0);";
checkError (error);
}
}
LedgerIndex
SHAMapStoreImp::SavedStateDB::getCanDelete()
{
beast::Error error;
LedgerIndex seq;
std::lock_guard<std::mutex> lock (mutex_);
{
std::lock_guard <std::mutex> lock (mutex_);
session_.once (error) <<
session_ <<
"SELECT CanDeleteSeq FROM CanDelete WHERE Key = 1;"
, beast::sqdb::into (seq);
, soci::into (seq);
;
}
checkError (error);
return seq;
}
@@ -111,16 +104,12 @@ SHAMapStoreImp::SavedStateDB::getCanDelete()
LedgerIndex
SHAMapStoreImp::SavedStateDB::setCanDelete (LedgerIndex canDelete)
{
beast::Error error;
{
std::lock_guard <std::mutex> lock (mutex_);
std::lock_guard<std::mutex> lock (mutex_);
session_.once (error) <<
"UPDATE CanDelete SET CanDeleteSeq = ? WHERE Key = 1;"
, beast::sqdb::use (canDelete)
session_ <<
"UPDATE CanDelete SET CanDeleteSeq = :canDelete WHERE Key = 1;"
, soci::use (canDelete)
;
}
checkError (error);
return canDelete;
}
@@ -128,21 +117,16 @@ SHAMapStoreImp::SavedStateDB::setCanDelete (LedgerIndex canDelete)
SHAMapStoreImp::SavedState
SHAMapStoreImp::SavedStateDB::getState()
{
beast::Error error;
SavedState state;
{
std::lock_guard <std::mutex> lock (mutex_);
std::lock_guard<std::mutex> lock (mutex_);
session_.once (error) <<
session_ <<
"SELECT WritableDb, ArchiveDb, LastRotatedLedger"
" FROM DbState WHERE Key = 1;"
, beast::sqdb::into (state.writableDb)
, beast::sqdb::into (state.archiveDb)
, beast::sqdb::into (state.lastRotated)
, soci::into (state.writableDb), soci::into (state.archiveDb)
, soci::into (state.lastRotated)
;
}
checkError (error);
return state;
}
@@ -150,48 +134,28 @@ SHAMapStoreImp::SavedStateDB::getState()
void
SHAMapStoreImp::SavedStateDB::setState (SavedState const& state)
{
beast::Error error;
{
std::lock_guard <std::mutex> lock (mutex_);
session_.once (error) <<
std::lock_guard<std::mutex> lock (mutex_);
session_ <<
"UPDATE DbState"
" SET WritableDb = ?,"
" ArchiveDb = ?,"
" LastRotatedLedger = ?"
" SET WritableDb = :writableDb,"
" ArchiveDb = :archiveDb,"
" LastRotatedLedger = :lastRotated"
" WHERE Key = 1;"
, beast::sqdb::use (state.writableDb)
, beast::sqdb::use (state.archiveDb)
, beast::sqdb::use (state.lastRotated)
, soci::use (state.writableDb)
, soci::use (state.archiveDb)
, soci::use (state.lastRotated)
;
}
checkError (error);
}
void
SHAMapStoreImp::SavedStateDB::setLastRotated (LedgerIndex seq)
{
beast::Error error;
{
std::lock_guard <std::mutex> lock (mutex_);
session_.once (error) <<
"UPDATE DbState SET LastRotatedLedger = ?"
std::lock_guard<std::mutex> lock (mutex_);
session_ <<
"UPDATE DbState SET LastRotatedLedger = :seq"
" WHERE Key = 1;"
, beast::sqdb::use (seq)
, soci::use (seq)
;
}
checkError (error);
}
void
SHAMapStoreImp::SavedStateDB::checkError (beast::Error const& error)
{
if (error)
{
journal_.fatal << "state database error: " << error.code()
<< ": " << error.getReasonText();
throw std::runtime_error ("State database error.");
}
}
SHAMapStoreImp::SHAMapStoreImp (Setup const& setup,
@@ -199,7 +163,8 @@ SHAMapStoreImp::SHAMapStoreImp (Setup const& setup,
NodeStore::Scheduler& scheduler,
beast::Journal journal,
beast::Journal nodeStoreJournal,
TransactionMaster& transactionMaster)
TransactionMaster& transactionMaster,
BasicConfig const& config)
: SHAMapStore (parent)
, setup_ (setup)
, scheduler_ (scheduler)
@@ -223,7 +188,7 @@ SHAMapStoreImp::SHAMapStoreImp (Setup const& setup,
std::to_string (setup_.ledgerHistory) + ")");
}
state_db_.init (setup_.databasePath, dbName_);
state_db_.init (config, dbName_);
dbPaths();
}
@@ -718,10 +683,12 @@ make_SHAMapStore (SHAMapStore::Setup const& s,
NodeStore::Scheduler& scheduler,
beast::Journal journal,
beast::Journal nodeStoreJournal,
TransactionMaster& transactionMaster)
TransactionMaster& transactionMaster,
BasicConfig const& config)
{
return std::make_unique<SHAMapStoreImp> (s, parent, scheduler,
journal, nodeStoreJournal, transactionMaster);
return std::make_unique<SHAMapStoreImp>(s, parent, scheduler,
journal, nodeStoreJournal, transactionMaster,
config);
}
}

View File

@@ -23,9 +23,9 @@
#include <ripple/app/data/DatabaseCon.h>
#include <ripple/app/misc/SHAMapStore.h>
#include <ripple/app/misc/NetworkOPs.h>
#include <ripple/app/data/SociDB.h>
#include <ripple/nodestore/impl/Tuning.h>
#include <ripple/nodestore/DatabaseRotating.h>
#include <beast/module/sqdb/sqdb.h>
#include <iostream>
#include <condition_variable>
#include <thread>

View File

@@ -20,6 +20,8 @@
#ifndef RIPPLE_CORE_CONFIGSECTIONS_H_INCLUDED
#define RIPPLE_CORE_CONFIGSECTIONS_H_INCLUDED
#include <string>
namespace ripple {
// VFALCO DEPRECATED in favor of the BasicConfig interface

View File

@@ -20,6 +20,7 @@
#include <BeastConfig.h>
#include <ripple/core/impl/LoadFeeTrackImp.h>
#include <ripple/core/Config.h>
#include <ripple/core/ConfigSections.h>
#include <ripple/basics/TestSuite.h>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>

View File

@@ -121,9 +121,9 @@ OverlayImpl::OverlayImpl (
Stoppable& parent,
ServerHandler& serverHandler,
Resource::Manager& resourceManager,
beast::File const& pathToDbFileOrDirectory,
Resolver& resolver,
boost::asio::io_service& io_service)
boost::asio::io_service& io_service,
BasicConfig const& config)
: Overlay (parent)
, io_service_ (io_service)
, work_ (boost::in_place(std::ref(io_service_)))
@@ -133,8 +133,7 @@ OverlayImpl::OverlayImpl (
, serverHandler_(serverHandler)
, m_resourceManager (resourceManager)
, m_peerFinder (PeerFinder::make_Manager (*this, io_service,
pathToDbFileOrDirectory, get_seconds_clock(),
deprecatedLogs().journal("PeerFinder")))
get_seconds_clock(), deprecatedLogs().journal("PeerFinder"), config))
, m_resolver (resolver)
, next_id_(1)
{
@@ -752,12 +751,12 @@ make_Overlay (
beast::Stoppable& parent,
ServerHandler& serverHandler,
Resource::Manager& resourceManager,
beast::File const& pathToDbFileOrDirectory,
Resolver& resolver,
boost::asio::io_service& io_service)
boost::asio::io_service& io_service,
BasicConfig const& config)
{
return std::make_unique <OverlayImpl> (setup, parent, serverHandler,
resourceManager, pathToDbFileOrDirectory, resolver, io_service);
resourceManager, resolver, io_service, config);
}
}

View File

@@ -44,6 +44,7 @@
namespace ripple {
class PeerImp;
class BasicConfig;
class OverlayImpl : public Overlay
{
@@ -122,8 +123,8 @@ private:
public:
OverlayImpl (Setup const& setup, Stoppable& parent,
ServerHandler& serverHandler, Resource::Manager& resourceManager,
beast::File const& pathToDbFileOrDirectory,
Resolver& resolver, boost::asio::io_service& io_service);
Resolver& resolver, boost::asio::io_service& io_service,
BasicConfig const& config);
~OverlayImpl();

View File

@@ -41,9 +41,9 @@ make_Overlay (
beast::Stoppable& parent,
ServerHandler& serverHandler,
Resource::Manager& resourceManager,
beast::File const& pathToDbFileOrDirectory,
Resolver& resolver,
boost::asio::io_service& io_service);
boost::asio::io_service& io_service,
BasicConfig const& config);
} // ripple

View File

@@ -23,6 +23,7 @@
#include <ripple/peerfinder/impl/Logic.h>
#include <ripple/peerfinder/impl/SourceStrings.h>
#include <ripple/peerfinder/impl/StoreSqdb.h>
#include <ripple/app/data/SociDB.h>
#include <boost/asio/io_service.hpp>
#include <boost/optional.hpp>
#include <beast/cxx14/memory.h> // <memory>
@@ -37,33 +38,31 @@ class ManagerImp
public:
boost::asio::io_service &io_service_;
boost::optional <boost::asio::io_service::work> work_;
beast::File m_databaseFile;
clock_type& m_clock;
beast::Journal m_journal;
StoreSqdb m_store;
Checker<boost::asio::ip::tcp> checker_;
Logic <decltype(checker_)> m_logic;
SociConfig m_sociConfig;
//--------------------------------------------------------------------------
ManagerImp (
Stoppable& stoppable,
boost::asio::io_service& io_service,
beast::File const& pathToDbFileOrDirectory,
clock_type& clock,
beast::Journal journal)
beast::Journal journal,
BasicConfig const& config)
: Manager (stoppable)
, io_service_(io_service)
, work_(boost::in_place(std::ref(io_service_)))
, m_databaseFile (pathToDbFileOrDirectory)
, m_clock (clock)
, m_journal (journal)
, m_store (journal)
, checker_ (io_service_)
, m_logic (clock, m_store, checker_, journal)
, m_sociConfig (config, "peerfinder")
{
if (m_databaseFile.isDirectory ())
m_databaseFile = m_databaseFile.getChildFile("peerfinder.sqlite");
}
~ManagerImp()
@@ -214,11 +213,7 @@ public:
void
onPrepare ()
{
beast::Error error (m_store.open (m_databaseFile));
if (error)
m_journal.fatal <<
"Failed to open '" << m_databaseFile.getFullPathName() << "'";
if (! error)
m_store.open (m_sociConfig);
m_logic.load ();
}
@@ -255,10 +250,10 @@ Manager::Manager (Stoppable& parent)
std::unique_ptr<Manager>
make_Manager (beast::Stoppable& parent, boost::asio::io_service& io_service,
beast::File const& databaseFile, clock_type& clock, beast::Journal journal)
clock_type& clock, beast::Journal journal, BasicConfig const& config)
{
return std::make_unique<ManagerImp> (
parent, io_service, databaseFile, clock, journal);
parent, io_service, clock, journal, config);
}
}

View File

@@ -20,7 +20,7 @@
#ifndef RIPPLE_PEERFINDER_STORESQDB_H_INCLUDED
#define RIPPLE_PEERFINDER_STORESQDB_H_INCLUDED
#include <beast/module/sqdb/sqdb.h>
#include <ripple/app/data/SociDB.h>
#include <beast/utility/Debug.h>
namespace ripple {
@@ -32,8 +32,7 @@ class StoreSqdb
{
private:
beast::Journal m_journal;
beast::sqdb::session m_session;
soci::session m_session;
public:
enum
{
@@ -50,19 +49,15 @@ public:
{
}
beast::Error open (beast::File const& file)
void open (SociConfig const& sociConfig)
{
beast::Error error (m_session.open (file.getFullPathName ()));
sociConfig.open (m_session);
m_journal.info << "Opening database at '" << file.getFullPathName() << "'";
m_journal.info << "Opening database at '" << sociConfig.connectionString ()
<< "'";
if (! error)
error = init ();
if (! error)
error = update ();
return error;
init ();
update ();
}
// Loads the bootstrap cache, calling the callback for each entry
@@ -70,26 +65,24 @@ public:
std::size_t load (load_callback const& cb)
{
std::size_t n (0);
beast::Error error;
std::string s;
int valence;
beast::sqdb::statement st = (m_session.prepare <<
soci::statement st = (m_session.prepare <<
"SELECT "
" address, "
" valence "
"FROM PeerFinder_BootstrapCache "
, beast::sqdb::into (s)
, beast::sqdb::into (valence)
, soci::into (s)
, soci::into (valence)
);
if (st.execute_and_fetch (error))
{
do
st.execute ();
while (st.fetch ())
{
beast::IP::Endpoint const endpoint (
beast::IP::Endpoint::from_string (s));
if (! is_unspecified (endpoint))
if (!is_unspecified (endpoint))
{
cb (endpoint, valence);
++n;
@@ -100,12 +93,6 @@ public:
"Bad address string '" << s << "' in Bootcache table";
}
}
while (st.fetch (error));
}
if (error)
report (error, __FILE__, __LINE__);
return n;
}
@@ -113,95 +100,75 @@ public:
//
void save (std::vector <Entry> const& v)
{
beast::Error error;
beast::sqdb::transaction tr (m_session);
m_session.once (error) <<
soci::transaction tr (m_session);
m_session <<
"DELETE FROM PeerFinder_BootstrapCache";
if (! error)
{
std::string s;
int valence;
beast::sqdb::statement st = (m_session.prepare <<
soci::statement st = (m_session.prepare <<
"INSERT INTO PeerFinder_BootstrapCache ( "
" address, "
" valence "
") VALUES ( "
" ?, ? "
" :s, :valence "
");"
, beast::sqdb::use (s)
, beast::sqdb::use (valence)
, soci::use (s)
, soci::use (valence)
);
for (auto const& e : v)
{
s = to_string (e.endpoint);
valence = e.valence;
st.execute_and_fetch (error);
if (error)
break;
}
st.execute ();
st.fetch ();
}
if (! error)
error = tr.commit();
if (error)
{
tr.rollback ();
report (error, __FILE__, __LINE__);
}
tr.commit ();
}
// Convert any existing entries from an older schema to the
// current one, if appropriate.
//
beast::Error update ()
void update ()
{
beast::Error error;
beast::sqdb::transaction tr (m_session);
soci::transaction tr (m_session);
// get version
int version (0);
if (! error)
{
m_session.once (error) <<
m_session <<
"SELECT "
" version "
"FROM SchemaVersion WHERE "
" name = 'PeerFinder'"
,beast::sqdb::into (version)
, soci::into (version)
;
if (! error)
{
if (!m_session.got_data())
if (!m_session.got_data ())
version = 0;
m_journal.info <<
"Opened version " << version << " database";
}
}
if (!error)
{
if (version < currentSchemaVersion)
m_journal.info <<
"Updating database to version " << currentSchemaVersion;
else if (version > currentSchemaVersion)
error.fail (__FILE__, __LINE__,
{
throw std::runtime_error (
"The PeerFinder database version is higher than expected");
}
}
if (! error && version < 4)
if (version < 4)
{
//
// Remove the "uptime" column from the bootstrap table
//
if (! error)
m_session.once (error) <<
m_session <<
"CREATE TABLE IF NOT EXISTS PeerFinder_BootstrapCache_Next ( "
" id INTEGER PRIMARY KEY AUTOINCREMENT, "
" address TEXT UNIQUE NOT NULL, "
@@ -209,8 +176,7 @@ public:
");"
;
if (! error)
m_session.once (error) <<
m_session <<
"CREATE INDEX IF NOT EXISTS "
" PeerFinder_BootstrapCache_Next_Index ON "
" PeerFinder_BootstrapCache_Next "
@@ -218,35 +184,32 @@ public:
;
std::size_t count;
if (! error)
m_session.once (error) <<
m_session <<
"SELECT COUNT(*) FROM PeerFinder_BootstrapCache "
,beast::sqdb::into (count)
, soci::into (count)
;
std::vector <Store::Entry> list;
if (! error)
{
list.reserve (count);
std::string s;
int valence;
beast::sqdb::statement st = (m_session.prepare <<
soci::statement st = (m_session.prepare <<
"SELECT "
" address, "
" valence "
"FROM PeerFinder_BootstrapCache "
, beast::sqdb::into (s)
, beast::sqdb::into (valence)
, soci::into (s)
, soci::into (valence)
);
if (st.execute_and_fetch (error))
{
do
st.execute ();
while (st.fetch ())
{
Store::Entry entry;
entry.endpoint = beast::IP::Endpoint::from_string (s);
if (! is_unspecified (entry.endpoint))
if (!is_unspecified (entry.endpoint))
{
entry.valence = valence;
list.push_back (entry);
@@ -257,126 +220,100 @@ public:
"Bad address string '" << s << "' in Bootcache table";
}
}
while (st.fetch (error));
}
}
if (! error)
{
std::string s;
int valence;
beast::sqdb::statement st = (m_session.prepare <<
soci::statement st = (m_session.prepare <<
"INSERT INTO PeerFinder_BootstrapCache_Next ( "
" address, "
" valence "
") VALUES ( "
" ?, ?"
" :s, :valence"
");"
, beast::sqdb::use (s)
, beast::sqdb::use (valence)
, soci::use (s)
, soci::use (valence)
);
for (auto iter (list.cbegin());
!error && iter != list.cend(); ++iter)
for (auto iter (list.cbegin ());
iter != list.cend (); ++iter)
{
s = to_string (iter->endpoint);
valence = iter->valence;
st.execute_and_fetch (error);
st.execute ();
st.fetch ();
}
}
}
if (! error)
m_session.once (error) <<
m_session <<
"DROP TABLE IF EXISTS PeerFinder_BootstrapCache";
if (! error)
m_session.once (error) <<
m_session <<
"DROP INDEX IF EXISTS PeerFinder_BootstrapCache_Index";
if (! error)
m_session.once (error) <<
m_session <<
"ALTER TABLE PeerFinder_BootstrapCache_Next "
" RENAME TO PeerFinder_BootstrapCache";
if (! error)
m_session.once (error) <<
m_session <<
"CREATE INDEX IF NOT EXISTS "
" PeerFinder_BootstrapCache_Index ON PeerFinder_BootstrapCache "
" PeerFinder_BootstrapCache_Index ON "
"PeerFinder_BootstrapCache "
" ( "
" address "
" ); "
;
}
if (! error && version < 3)
if (version < 3)
{
//
// Remove legacy endpoints from the schema
//
if (! error)
m_session.once (error) <<
m_session <<
"DROP TABLE IF EXISTS LegacyEndpoints";
if (! error)
m_session.once (error) <<
m_session <<
"DROP TABLE IF EXISTS PeerFinderLegacyEndpoints";
if (! error)
m_session.once (error) <<
m_session <<
"DROP TABLE IF EXISTS PeerFinder_LegacyEndpoints";
if (! error)
m_session.once (error) <<
m_session <<
"DROP TABLE IF EXISTS PeerFinder_LegacyEndpoints_Index";
}
if (! error)
{
int const version (currentSchemaVersion);
m_session.once (error) <<
m_session <<
"INSERT OR REPLACE INTO SchemaVersion ("
" name "
" ,version "
") VALUES ( "
" 'PeerFinder', ? "
" 'PeerFinder', :version "
")"
,beast::sqdb::use(version);
, soci::use (version);
}
if (! error)
error = tr.commit();
if (error)
{
tr.rollback();
report (error, __FILE__, __LINE__);
}
return error;
tr.commit ();
}
private:
beast::Error init ()
void init ()
{
beast::Error error;
beast::sqdb::transaction tr (m_session);
soci::transaction tr (m_session);
m_session << "PRAGMA encoding=\"UTF-8\"";
if (! error)
m_session.once (error) <<
"PRAGMA encoding=\"UTF-8\"";
if (! error)
m_session.once (error) <<
m_session <<
"CREATE TABLE IF NOT EXISTS SchemaVersion ( "
" name TEXT PRIMARY KEY, "
" version INTEGER"
");"
;
if (! error)
m_session.once (error) <<
m_session <<
"CREATE TABLE IF NOT EXISTS PeerFinder_BootstrapCache ( "
" id INTEGER PRIMARY KEY AUTOINCREMENT, "
" address TEXT UNIQUE NOT NULL, "
@@ -384,35 +321,16 @@ private:
");"
;
if (! error)
m_session.once (error) <<
m_session <<
"CREATE INDEX IF NOT EXISTS "
" PeerFinder_BootstrapCache_Index ON PeerFinder_BootstrapCache "
" PeerFinder_BootstrapCache_Index ON "
"PeerFinder_BootstrapCache "
" ( "
" address "
" ); "
;
if (! error)
error = tr.commit();
if (error)
{
tr.rollback ();
report (error, __FILE__, __LINE__);
}
return error;
}
void report (beast::Error const& error, char const* fileName, int lineNumber)
{
if (error)
{
m_journal.error <<
"Failure: '"<< error.getReasonText() << "' " <<
" at " << beast::Debug::getSourceLocation (fileName, lineNumber);
}
tr.commit ();
}
};

View File

@@ -30,8 +30,7 @@ namespace PeerFinder {
/** Create a new Manager. */
std::unique_ptr<Manager>
make_Manager (beast::Stoppable& parent, boost::asio::io_service& io_service,
beast::File const& pathToDbFileOrDirectory,
clock_type& clock, beast::Journal journal);
clock_type& clock, beast::Journal journal, BasicConfig const& config);
}
}

View File

@@ -30,7 +30,6 @@
// Include this to get all the basic includes included, to prevent errors
#include <beast/module/core/core.unity.cpp>
#include <beast/module/asio/asio.unity.cpp>
#include <beast/module/sqdb/sqdb.unity.cpp>
#include <beast/asio/Asio.unity.cpp>
#include <beast/boost/Boost.unity.cpp>

51
src/ripple/unity/soci.cpp Normal file
View File

@@ -0,0 +1,51 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012-2015 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <BeastConfig.h>
// Core soci
#include <core/connection-parameters.cpp>
#include <core/connection-pool.cpp>
#include <core/error.cpp>
#include <core/into-type.cpp>
#include <core/once-temp-type.cpp>
#include <core/prepare-temp-type.cpp>
#include <core/procedure.cpp>
#include <core/ref-counted-prepare-info.cpp>
#include <core/ref-counted-statement.cpp>
#include <core/row.cpp>
#include <core/rowid.cpp>
#include <core/session.cpp>
#include <core/soci-simple.cpp>
#include <core/statement.cpp>
#include <core/transaction.cpp>
#include <core/use-type.cpp>
#include <core/values.cpp>
#include <backends/sqlite3/common.cpp>
#include <backends/sqlite3/factory.cpp>
#include <backends/sqlite3/row-id.cpp>
#include <backends/sqlite3/session.cpp>
#include <backends/sqlite3/standard-into-type.cpp>
#include <backends/sqlite3/standard-use-type.cpp>
#include <backends/sqlite3/statement.cpp>
#include <backends/sqlite3/vector-into-type.cpp>
#include <backends/sqlite3/vector-use-type.cpp>
#include <core/blob.cpp>
#include <backends/sqlite3/blob.cpp>

View File

@@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <BeastConfig.h>
#include <ripple/app/data/DummySociDynamicBackend.cpp>
#include <ripple/app/data/SociDB.cpp>
#include <ripple/app/data/tests/SociDB.test.cpp>

View File

@@ -0,0 +1,48 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012-2015 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#if ENABLE_SOCI_POSTGRESQL
#if BEAST_INCLUDE_BEASTCONFIG
#include <BeastConfig.h>
#endif
#include <algorithm>
#if BEAST_MSVC
#define SOCI_LIB_PREFIX ""
#define SOCI_LIB_SUFFIX ".dll"
#else
#define SOCI_LIB_PREFIX "lib"
#define SOCI_LIB_SUFFIX ".so"
#endif
#include<backends/postgresql/blob.cpp>
#include<backends/postgresql/common.cpp>
#include<backends/postgresql/error.cpp>
#include<backends/postgresql/factory.cpp>
#include<backends/postgresql/row-id.cpp>
#include<backends/postgresql/session.cpp>
#include<backends/postgresql/standard-into-type.cpp>
#include<backends/postgresql/standard-use-type.cpp>
#include<backends/postgresql/statement.cpp>
#include<backends/postgresql/vector-into-type.cpp>
#include<backends/postgresql/vector-use-type.cpp>
#endif // ENABLE_SOCI_POSTGRESQL

View File

@@ -206,24 +206,21 @@ public:
boost::asio::basic_waitable_timer<
std::chrono::steady_clock> timer_;
beast::Journal journal_;
beast::File dbFile_;
StoreSqdb store_;
Logic logic_;
SociConfig sociConfig_;
ManagerImp (Stoppable& parent, boost::asio::io_service& io_service,
beast::File const& pathToDbFileOrDirectory, beast::Journal journal)
beast::Journal journal, BasicConfig const& config)
: Stoppable ("Validators::Manager", parent)
, io_service_(io_service)
, strand_(io_service_)
, timer_(io_service_)
, journal_ (journal)
, dbFile_ (pathToDbFileOrDirectory)
, store_ (journal_)
, logic_ (store_, journal_)
, sociConfig_ (config, "validators")
{
if (dbFile_.isDirectory ())
dbFile_ = dbFile_.getChildFile("validators.sqlite");
}
~ManagerImp()
@@ -293,13 +290,9 @@ public:
void init()
{
beast::Error error (store_.open (dbFile_));
if (! error)
{
store_.open (sociConfig_);
logic_.load ();
}
}
void
onTimer (boost::system::error_code ec)
@@ -331,12 +324,11 @@ Manager::Manager ()
std::unique_ptr<Manager>
make_Manager(beast::Stoppable& parent,
boost::asio::io_service& io_service,
beast::File const& pathToDbFileOrDirectory,
beast::Journal journal)
beast::Journal journal,
BasicConfig const& config)
{
return std::make_unique<ManagerImp> (parent,
io_service, pathToDbFileOrDirectory, journal);
}
return std::make_unique<ManagerImp>(parent,
io_service, journal, config);
}
}
}

View File

@@ -35,19 +35,12 @@ StoreSqdb::~StoreSqdb ()
{
}
beast::Error
StoreSqdb::open (beast::File const& file)
void
StoreSqdb::open (SociConfig const& sociConfig)
{
beast::Error error (m_session.open (file.getFullPathName ()));
sociConfig.open (m_session);
m_journal.info <<
"Opening " << file.getFullPathName();
if (error)
m_journal.error <<
"Failed opening database: " << error.what();
return error;
m_journal.info << "Opening " << sociConfig.connectionString ();
}
}

View File

@@ -22,9 +22,8 @@
#include <ripple/validators/impl/Store.h>
#include <beast/module/core/files/File.h>
#include <beast/module/sqdb/sqdb.h>
#include <beast/utility/Error.h>
#include <beast/utility/Journal.h>
#include <ripple/app/data/SociDB.h>
namespace ripple {
namespace Validators {
@@ -34,7 +33,7 @@ class StoreSqdb : public Store
{
private:
beast::Journal m_journal;
beast::sqdb::session m_session;
soci::session m_session;
public:
enum
@@ -48,8 +47,8 @@ public:
~StoreSqdb();
beast::Error
open (beast::File const& file);
void
open (SociConfig const& sociConfig);
};
}

View File

@@ -28,13 +28,14 @@
#include <memory>
namespace ripple {
class BasicConfig;
namespace Validators {
std::unique_ptr<Manager>
make_Manager (beast::Stoppable& stoppableParent,
boost::asio::io_service& io_service,
beast::File const& pathToDbFileOrDirectory,
beast::Journal journal);
beast::Journal journal,
BasicConfig const& config);
}
}

1
src/sqlite/sqlite3.h Normal file
View File

@@ -0,0 +1 @@
#include <beast/module/sqlite/sqlite/sqlite3.h>