Remove SqliteFactory.

This commit is contained in:
seelabs
2015-03-03 15:19:32 -08:00
committed by Vinnie Falco
parent 9b837a24aa
commit d37802a42f
5 changed files with 0 additions and 315 deletions

View File

@@ -1758,14 +1758,6 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\misc\Validations.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\node\SqliteFactory.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\node\SqliteFactory.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\paths\AccountCurrencies.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>

View File

@@ -283,9 +283,6 @@
<Filter Include="ripple\app\misc\tests">
<UniqueIdentifier>{815DC1A2-E2EF-E6E3-D979-19AD1476A28B}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\app\node">
<UniqueIdentifier>{0FCD3973-E9A6-7172-C8A3-C3401E1A03DD}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\app\paths">
<UniqueIdentifier>{03533509-DAC6-636F-9F7E-288894549E95}</UniqueIdentifier>
</Filter>
@@ -2409,12 +2406,6 @@
<ClInclude Include="..\..\src\ripple\app\misc\Validations.h">
<Filter>ripple\app\misc</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\node\SqliteFactory.cpp">
<Filter>ripple\app\node</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\node\SqliteFactory.h">
<Filter>ripple\app\node</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\paths\AccountCurrencies.cpp">
<Filter>ripple\app\paths</Filter>
</ClCompile>

View File

@@ -1,263 +0,0 @@
//------------------------------------------------------------------------------
/*
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/node/SqliteFactory.h>
#include <ripple/app/data/DatabaseCon.h>
#include <ripple/app/data/SqliteDatabase.h>
#include <ripple/core/Config.h>
#include <type_traits>
#include <beast/cxx14/memory.h> // <memory>
namespace ripple {
// VFALCO NOTE LedgerIndex in CommittedObjects is obsolete
static const char* s_nodeStoreDBInit [] =
{
"PRAGMA synchronous=NORMAL;",
"PRAGMA journal_mode=WAL;",
"PRAGMA journal_size_limit=1582080;",
#if (ULONG_MAX > UINT_MAX) && !defined (NO_SQLITE_MMAP)
"PRAGMA mmap_size=171798691840;",
#endif
"BEGIN TRANSACTION;",
"CREATE TABLE CommittedObjects ( \
Hash CHARACTER(64) PRIMARY KEY, \
ObjType CHAR(1) NOT NULL, \
LedgerIndex BIGINT UNSIGNED, \
Object BLOB \
);",
"END TRANSACTION;"
};
//------------------------------------------------------------------------------
class SqliteBackend : public NodeStore::Backend
{
public:
explicit SqliteBackend (std::string const& path, int hashnode_cache_size)
: m_name (path)
, m_db (new DatabaseCon(setup_DatabaseCon (getConfig()), path,
s_nodeStoreDBInit, std::extent<decltype(s_nodeStoreDBInit)>::value))
{
std::string s ("PRAGMA cache_size=-");
s += std::to_string (hashnode_cache_size);
m_db->getDB()->executeSQL (s);
}
~SqliteBackend()
{
}
std::string getName()
{
return m_name;
}
void
close() override
{
// VFALCO how do we do this?
assert(false);
}
//--------------------------------------------------------------------------
NodeStore::Status fetch (void const* key, NodeObject::Ptr* pObject)
{
NodeStore::Status result = NodeStore::ok;
pObject->reset ();
{
auto sl (m_db->lock());
uint256 const hash (uint256::fromVoid (key));
static SqliteStatement pSt (m_db->getDB()->getSqliteDB(),
"SELECT ObjType,Object FROM CommittedObjects WHERE Hash = ?;");
pSt.bind (1, to_string (hash));
if (pSt.isRow (pSt.step()))
{
// VFALCO NOTE This is unfortunately needed,
// the DatabaseCon creates the blob?
Blob data (pSt.getBlob(1));
*pObject = NodeObject::createObject (
getTypeFromString (pSt.peekString (0)),
std::move(data),
hash);
}
else
{
result = NodeStore::notFound;
}
pSt.reset();
}
return result;
}
void store (NodeObject::ref object)
{
NodeStore::Batch batch;
batch.push_back (object);
storeBatch (batch);
}
void storeBatch (NodeStore::Batch const& batch)
{
auto sl (m_db->lock());
static SqliteStatement pStB (m_db->getDB()->getSqliteDB(), "BEGIN TRANSACTION;");
static SqliteStatement pStE (m_db->getDB()->getSqliteDB(), "END TRANSACTION;");
static SqliteStatement pSt (m_db->getDB()->getSqliteDB(),
"INSERT OR IGNORE INTO CommittedObjects "
"(Hash,ObjType,Object) VALUES (?, ?, ?, ?);");
pStB.step();
pStB.reset();
for (NodeObject::Ptr const& object : batch)
{
doBind (pSt, object);
pSt.step();
pSt.reset();
}
pStE.step();
pStE.reset();
}
void for_each (std::function <void(NodeObject::Ptr)> f)
{
// No lock needed as per the for_each() API
uint256 hash;
static SqliteStatement pSt(m_db->getDB()->getSqliteDB(),
"SELECT ObjType,Object,Hash FROM CommittedObjects;");
while (pSt.isRow (pSt.step()))
{
hash.SetHexExact(pSt.getString(3));
// VFALCO NOTE This is unfortunately needed,
// the DatabaseCon creates the blob?
Blob data (pSt.getBlob (1));
NodeObject::Ptr const object (NodeObject::createObject (
getTypeFromString (pSt.peekString (0)),
std::move(data),
hash));
f (object);
}
pSt.reset ();
}
int getWriteLoad ()
{
return 0;
}
void setDeletePath() override {}
//--------------------------------------------------------------------------
void doBind (SqliteStatement& statement, NodeObject::ref object)
{
char const* type;
switch (object->getType())
{
case hotLEDGER: type = "L"; break;
case hotTRANSACTION: type = "T"; break;
case hotACCOUNT_NODE: type = "A"; break;
case hotTRANSACTION_NODE: type = "N"; break;
default: type = "U";
}
statement.bind(1, to_string (object->getHash()));
statement.bind(2, type);
statement.bindStatic(3, object->getData());
}
NodeObjectType getTypeFromString (std::string const& s)
{
NodeObjectType type = hotUNKNOWN;
if (!s.empty ())
{
switch (s [0])
{
case 'L': type = hotLEDGER; break;
case 'T': type = hotTRANSACTION; break;
case 'A': type = hotACCOUNT_NODE; break;
case 'N': type = hotTRANSACTION_NODE; break;
}
}
return type;
}
void
verify() override
{
}
private:
std::string const m_name;
std::unique_ptr <DatabaseCon> m_db;
};
//------------------------------------------------------------------------------
class SqliteFactory : public NodeStore::Factory
{
public:
SqliteFactory() = default;
std::string
getName () const
{
return "Sqlite";
}
std::unique_ptr <NodeStore::Backend> createInstance (
size_t, Section const& keyValues,
NodeStore::Scheduler&, beast::Journal)
{
return std::make_unique <SqliteBackend> (
get<std::string>(keyValues, "path"),
getConfig ().getSize(siHashNodeDBCache) * 1024);
}
};
static SqliteFactory sqliteFactory;
}

View File

@@ -1,34 +0,0 @@
//------------------------------------------------------------------------------
/*
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.
*/
//==============================================================================
#ifndef RIPPLE_APP_NODE_SQLITEFACTORY_H_INCLUDED
#define RIPPLE_APP_NODE_SQLITEFACTORY_H_INCLUDED
#include <ripple/nodestore/Factory.h>
namespace ripple {
/** Factory to produce SQLite backends for the NodeStore.
@see Database
*/
std::unique_ptr <NodeStore::Factory> make_SqliteFactory (int hashnode_cache_size);
}
#endif

View File

@@ -23,7 +23,6 @@
#include <ripple/app/main/CollectorManager.cpp>
#include <ripple/app/main/Main.cpp>
#include <ripple/app/main/NodeStoreScheduler.cpp>
#include <ripple/app/node/SqliteFactory.cpp>
#include <ripple/resource/Manager.h>
#include <ripple/rpc/Manager.h>
#include <beast/module/core/time/Time.h>