Rename to NodeObject

This commit is contained in:
Vinnie Falco
2013-07-10 10:28:15 -07:00
parent 4b5daa70c9
commit d6fb686426
16 changed files with 122 additions and 122 deletions

View File

@@ -25,7 +25,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\node\ripple_HashedObject.cpp">
<ClCompile Include="..\..\modules\ripple_app\node\ripple_NodeObject.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1342,7 +1342,7 @@
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_BuildVersion.h" />
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_RPCServerHandler.h" />
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_Version.h" />
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HashedObject.h" />
<ClInclude Include="..\..\modules\ripple_app\node\ripple_NodeObject.h" />
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HashedObjectStore.h" />
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HashStoreBE.h" />
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HSBELevelDB.h" />

View File

@@ -855,10 +855,10 @@
<ClCompile Include="..\..\modules\ripple_app\node\ripple_HSBESqlite.cpp">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\node\ripple_HashedObject.cpp">
<ClCompile Include="..\..\modules\ripple_app\node\ripple_HashedObjectStore.cpp">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClCompile>
<ClCompile Include="..\..\modules\ripple_app\node\ripple_HashedObjectStore.cpp">
<ClCompile Include="..\..\modules\ripple_app\node\ripple_NodeObject.cpp">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClCompile>
</ItemGroup>
@@ -1605,10 +1605,10 @@
<ClInclude Include="..\..\src\cpp\ripple\ripple_DBInit.h">
<Filter>[1] Ripple\ripple_app\_data</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HashedObject.h">
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HashedObjectStore.h">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HashedObjectStore.h">
<ClInclude Include="..\..\modules\ripple_app\node\ripple_NodeObject.h">
<Filter>[1] Ripple\ripple_app\node</Filter>
</ClInclude>
</ItemGroup>

View File

@@ -23,7 +23,7 @@ std::string HSBELevelDB::getDataBaseName()
return mName;
}
bool HSBELevelDB::store(HashedObject::ref obj)
bool HSBELevelDB::store(NodeObject::ref obj)
{
Blob blob (toBlob (obj));
return mDB->Put (leveldb::WriteOptions (),
@@ -31,11 +31,11 @@ bool HSBELevelDB::store(HashedObject::ref obj)
leveldb::Slice (reinterpret_cast<char const*>(&blob.front ()), blob.size ())).ok ();
}
bool HSBELevelDB::bulkStore(const std::vector< HashedObject::pointer >& objs)
bool HSBELevelDB::bulkStore(const std::vector< NodeObject::pointer >& objs)
{
leveldb::WriteBatch batch;
BOOST_FOREACH (HashedObject::ref obj, objs)
BOOST_FOREACH (NodeObject::ref obj, objs)
{
Blob blob (toBlob (obj));
batch.Put (
@@ -45,18 +45,18 @@ bool HSBELevelDB::bulkStore(const std::vector< HashedObject::pointer >& objs)
return mDB->Write (leveldb::WriteOptions (), &batch).ok ();
}
HashedObject::pointer HSBELevelDB::retrieve(uint256 const& hash)
NodeObject::pointer HSBELevelDB::retrieve(uint256 const& hash)
{
std::string sData;
if (!mDB->Get (leveldb::ReadOptions (),
leveldb::Slice (reinterpret_cast<char const*>(hash.begin ()), 256 / 8), &sData).ok ())
{
return HashedObject::pointer();
return NodeObject::pointer();
}
return fromBinary(hash, &sData[0], sData.size ());
}
void HSBELevelDB::visitAll(FUNCTION_TYPE<void (HashedObject::pointer)> func)
void HSBELevelDB::visitAll(FUNCTION_TYPE<void (NodeObject::pointer)> func)
{
leveldb::Iterator* it = mDB->NewIterator (leveldb::ReadOptions ());
for (it->SeekToFirst (); it->Valid (); it->Next ())
@@ -70,7 +70,7 @@ void HSBELevelDB::visitAll(FUNCTION_TYPE<void (HashedObject::pointer)> func)
}
}
Blob HSBELevelDB::toBlob(HashedObject::ref obj)
Blob HSBELevelDB::toBlob(NodeObject::ref obj)
{
Blob rawData (9 + obj->getData ().size ());
unsigned char* bufPtr = &rawData.front();
@@ -83,7 +83,7 @@ Blob HSBELevelDB::toBlob(HashedObject::ref obj)
return rawData;
}
HashedObject::pointer HSBELevelDB::fromBinary(uint256 const& hash,
NodeObject::pointer HSBELevelDB::fromBinary(uint256 const& hash,
char const* data, int size)
{
if (size < 9)
@@ -92,6 +92,6 @@ HashedObject::pointer HSBELevelDB::fromBinary(uint256 const& hash,
uint32 index = htonl (*reinterpret_cast<const uint32*> (data));
int htype = data[8];
return boost::make_shared<HashedObject> (static_cast<HashedObjectType> (htype), index,
return boost::make_shared<NodeObject> (static_cast<NodeObjectType> (htype), index,
data + 9, size - 9, hash);
}

View File

@@ -14,19 +14,19 @@ public:
std::string getDataBaseName();
bool store(HashedObject::ref);
bool bulkStore(const std::vector< HashedObject::pointer >&);
bool store(NodeObject::ref);
bool bulkStore(const std::vector< NodeObject::pointer >&);
HashedObject::pointer retrieve(uint256 const& hash);
NodeObject::pointer retrieve(uint256 const& hash);
void visitAll(FUNCTION_TYPE<void (HashedObject::pointer)>);
void visitAll(FUNCTION_TYPE<void (NodeObject::pointer)>);
private:
std::string mName;
leveldb::DB* mDB;
Blob toBlob(HashedObject::ref);
HashedObject::pointer fromBinary(uint256 const& hash, char const* data, int size);
Blob toBlob(NodeObject::ref);
NodeObject::pointer fromBinary(uint256 const& hash, char const* data, int size);
};
#endif

View File

@@ -16,7 +16,7 @@ std::string HSBESQLite::getDataBaseName()
return mName;
}
bool HSBESQLite::store(HashedObject::ref object)
bool HSBESQLite::store(NodeObject::ref object)
{
ScopedLock sl(mDb->getDBLock());
static SqliteStatement pSt(mDb->getDB()->getSqliteDB(),
@@ -28,7 +28,7 @@ bool HSBESQLite::store(HashedObject::ref object)
return true;
}
bool HSBESQLite::bulkStore(const std::vector< HashedObject::pointer >& objects)
bool HSBESQLite::bulkStore(const std::vector< NodeObject::pointer >& objects)
{
ScopedLock sl(mDb->getDBLock());
static SqliteStatement pStB(mDb->getDB()->getSqliteDB(), "BEGIN TRANSACTION;");
@@ -40,7 +40,7 @@ bool HSBESQLite::bulkStore(const std::vector< HashedObject::pointer >& objects)
pStB.step();
pStB.reset();
BOOST_FOREACH(HashedObject::ref object, objects)
BOOST_FOREACH(NodeObject::ref object, objects)
{
bind(pSt, object);
pSt.step();
@@ -54,9 +54,9 @@ bool HSBESQLite::bulkStore(const std::vector< HashedObject::pointer >& objects)
}
HashedObject::pointer HSBESQLite::retrieve(uint256 const& hash)
NodeObject::pointer HSBESQLite::retrieve(uint256 const& hash)
{
HashedObject::pointer ret;
NodeObject::pointer ret;
{
ScopedLock sl(mDb->getDBLock());
@@ -66,7 +66,7 @@ HashedObject::pointer HSBESQLite::retrieve(uint256 const& hash)
pSt.bind(1, hash.GetHex());
if (pSt.isRow(pSt.step()))
ret = boost::make_shared<HashedObject>(getType(pSt.peekString(0)), pSt.getUInt32(1), pSt.getBlob(2), hash);
ret = boost::make_shared<NodeObject>(getType(pSt.peekString(0)), pSt.getUInt32(1), pSt.getBlob(2), hash);
pSt.reset();
}
@@ -74,7 +74,7 @@ HashedObject::pointer HSBESQLite::retrieve(uint256 const& hash)
return ret;
}
void HSBESQLite::visitAll(FUNCTION_TYPE<void (HashedObject::pointer)> func)
void HSBESQLite::visitAll(FUNCTION_TYPE<void (NodeObject::pointer)> func)
{
uint256 hash;
@@ -84,13 +84,13 @@ void HSBESQLite::visitAll(FUNCTION_TYPE<void (HashedObject::pointer)> func)
while (pSt.isRow(pSt.step()))
{
hash.SetHexExact(pSt.getString(3));
func(boost::make_shared<HashedObject>(getType(pSt.peekString(0)), pSt.getUInt32(1), pSt.getBlob(2), hash));
func(boost::make_shared<NodeObject>(getType(pSt.peekString(0)), pSt.getUInt32(1), pSt.getBlob(2), hash));
}
pSt.reset();
}
void HSBESQLite::bind(SqliteStatement& statement, HashedObject::ref object)
void HSBESQLite::bind(SqliteStatement& statement, NodeObject::ref object)
{
char const* type;
switch (object->getType())
@@ -108,9 +108,9 @@ void HSBESQLite::bind(SqliteStatement& statement, HashedObject::ref object)
statement.bindStatic(4, object->getData());
}
HashedObjectType HSBESQLite::getType(std::string const& type)
NodeObjectType HSBESQLite::getType(std::string const& type)
{
HashedObjectType htype = hotUNKNOWN;
NodeObjectType htype = hotUNKNOWN;
if (!type.empty())
{
switch (type[0])

View File

@@ -14,19 +14,19 @@ public:
std::string getDataBaseName();
bool store(HashedObject::ref);
bool bulkStore(const std::vector< HashedObject::pointer >&);
bool store(NodeObject::ref);
bool bulkStore(const std::vector< NodeObject::pointer >&);
HashedObject::pointer retrieve(uint256 const& hash);
NodeObject::pointer retrieve(uint256 const& hash);
void visitAll(FUNCTION_TYPE<void (HashedObject::pointer)>);
void visitAll(FUNCTION_TYPE<void (NodeObject::pointer)>);
private:
std::string mName;
DatabaseCon* mDb;
void bind(SqliteStatement& statement, HashedObject::ref object);
HashedObjectType getType(std::string const&);
void bind(SqliteStatement& statement, NodeObject::ref object);
NodeObjectType getType(std::string const&);
};
#endif

View File

@@ -16,16 +16,16 @@ public:
// Store/retrieve a single object
// These functions must be thread safe
virtual bool store(HashedObject::ref) = 0;
virtual HashedObject::pointer retrieve(uint256 const &hash) = 0;
virtual bool store(NodeObject::ref) = 0;
virtual NodeObject::pointer retrieve(uint256 const &hash) = 0;
// Store a group of objects
// This function will only be called from a single thread
virtual bool bulkStore(const std::vector< HashedObject::pointer >&) = 0;
virtual bool bulkStore(const std::vector< NodeObject::pointer >&) = 0;
// Visit every object in the database
// This function will only be called during an import operation
virtual void visitAll(FUNCTION_TYPE<void (HashedObject::pointer)>) = 0;
virtual void visitAll(FUNCTION_TYPE<void (NodeObject::pointer)>) = 0;
};
#endif

View File

@@ -16,7 +16,7 @@ HashedObjectStore::HashedObjectStore (int cacheSize, int cacheAge) :
mLevelDB = false;
else
{
WriteLog (lsFATAL, HashedObject) << "Incorrect database selection";
WriteLog (lsFATAL, NodeObject) << "Incorrect database selection";
assert (false);
}
@@ -46,7 +46,7 @@ int HashedObjectStore::getWriteLoad ()
}
// low-level retrieve
HashedObject::pointer HashedObjectStore::LLRetrieve (uint256 const& hash, leveldb::DB* db)
NodeObject::pointer HashedObjectStore::LLRetrieve (uint256 const& hash, leveldb::DB* db)
{
std::string sData;
@@ -56,21 +56,21 @@ HashedObject::pointer HashedObjectStore::LLRetrieve (uint256 const& hash, leveld
if (!st.ok ())
{
assert (st.IsNotFound ());
return HashedObject::pointer ();
return NodeObject::pointer ();
}
const unsigned char* bufPtr = reinterpret_cast<const unsigned char*> (&sData[0]);
uint32 index = htonl (*reinterpret_cast<const uint32*> (bufPtr));
int htype = bufPtr[8];
return boost::make_shared<HashedObject> (static_cast<HashedObjectType> (htype), index,
return boost::make_shared<NodeObject> (static_cast<NodeObjectType> (htype), index,
bufPtr + 9, sData.size () - 9, hash);
}
// low-level write single
void HashedObjectStore::LLWrite (boost::shared_ptr<HashedObject> ptr, leveldb::DB* db)
void HashedObjectStore::LLWrite (boost::shared_ptr<NodeObject> ptr, leveldb::DB* db)
{
HashedObject& obj = *ptr;
NodeObject& obj = *ptr;
Blob rawData (9 + obj.getData ().size ());
unsigned char* bufPtr = &rawData.front ();
@@ -85,19 +85,19 @@ void HashedObjectStore::LLWrite (boost::shared_ptr<HashedObject> ptr, leveldb::D
if (!st.ok ())
{
WriteLog (lsFATAL, HashedObject) << "Failed to store hash node";
WriteLog (lsFATAL, NodeObject) << "Failed to store hash node";
assert (false);
}
}
// low-level write set
void HashedObjectStore::LLWrite (const std::vector< boost::shared_ptr<HashedObject> >& set, leveldb::DB* db)
void HashedObjectStore::LLWrite (const std::vector< boost::shared_ptr<NodeObject> >& set, leveldb::DB* db)
{
leveldb::WriteBatch batch;
BOOST_FOREACH (const boost::shared_ptr<HashedObject>& it, set)
BOOST_FOREACH (const boost::shared_ptr<NodeObject>& it, set)
{
const HashedObject& obj = *it;
const NodeObject& obj = *it;
Blob rawData (9 + obj.getData ().size ());
unsigned char* bufPtr = &rawData.front ();
@@ -114,12 +114,12 @@ void HashedObjectStore::LLWrite (const std::vector< boost::shared_ptr<HashedObje
if (!st.ok ())
{
WriteLog (lsFATAL, HashedObject) << "Failed to store hash node";
WriteLog (lsFATAL, NodeObject) << "Failed to store hash node";
assert (false);
}
}
bool HashedObjectStore::storeLevelDB (HashedObjectType type, uint32 index,
bool HashedObjectStore::storeLevelDB (NodeObjectType type, uint32 index,
Blob const& data, uint256 const& hash)
{
// return: false = already in cache, true = added to cache
@@ -133,7 +133,7 @@ bool HashedObjectStore::storeLevelDB (HashedObjectType type, uint32 index,
assert (hash == Serializer::getSHA512Half (data));
#endif
HashedObject::pointer object = boost::make_shared<HashedObject> (type, index, data, hash);
NodeObject::pointer object = boost::make_shared<NodeObject> (type, index, data, hash);
if (!mCache.canonicalize (hash, object))
{
@@ -143,7 +143,7 @@ bool HashedObjectStore::storeLevelDB (HashedObjectType type, uint32 index,
if (!mWritePending)
{
mWritePending = true;
getApp().getJobQueue ().addJob (jtWRITE, "HashedObject::store",
getApp().getJobQueue ().addJob (jtWRITE, "NodeObject::store",
BIND_TYPE (&HashedObjectStore::bulkWriteLevelDB, this, P_1));
}
}
@@ -159,7 +159,7 @@ void HashedObjectStore::bulkWriteLevelDB (Job&)
while (1)
{
std::vector< boost::shared_ptr<HashedObject> > set;
std::vector< boost::shared_ptr<NodeObject> > set;
set.reserve (128);
{
@@ -188,9 +188,9 @@ void HashedObjectStore::bulkWriteLevelDB (Job&)
}
}
HashedObject::pointer HashedObjectStore::retrieveLevelDB (uint256 const& hash)
NodeObject::pointer HashedObjectStore::retrieveLevelDB (uint256 const& hash)
{
HashedObject::pointer obj = mCache.fetch (hash);
NodeObject::pointer obj = mCache.fetch (hash);
if (obj || mNegativeCache.isPresent (hash) || !getApp().getHashNodeLDB ())
return obj;
@@ -222,46 +222,46 @@ HashedObject::pointer HashedObjectStore::retrieveLevelDB (uint256 const& hash)
if (mEphemeralDB)
LLWrite (obj, getApp().getEphemeralLDB ());
WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " fetch: in db";
WriteLog (lsTRACE, NodeObject) << "HOS: " << hash << " fetch: in db";
return obj;
}
bool HashedObjectStore::storeSQLite (HashedObjectType type, uint32 index,
bool HashedObjectStore::storeSQLite (NodeObjectType type, uint32 index,
Blob const& data, uint256 const& hash)
{
// return: false = already in cache, true = added to cache
if (!getApp().getHashNodeDB ())
{
WriteLog (lsTRACE, HashedObject) << "HOS: no db";
WriteLog (lsTRACE, NodeObject) << "HOS: no db";
return true;
}
if (mCache.touch (hash))
{
WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " store: incache";
WriteLog (lsTRACE, NodeObject) << "HOS: " << hash << " store: incache";
return false;
}
assert (hash == Serializer::getSHA512Half (data));
HashedObject::pointer object = boost::make_shared<HashedObject> (type, index, data, hash);
NodeObject::pointer object = boost::make_shared<NodeObject> (type, index, data, hash);
if (!mCache.canonicalize (hash, object))
{
// WriteLog (lsTRACE, HashedObject) << "Queuing write for " << hash;
// WriteLog (lsTRACE, NodeObject) << "Queuing write for " << hash;
boost::mutex::scoped_lock sl (mWriteMutex);
mWriteSet.push_back (object);
if (!mWritePending)
{
mWritePending = true;
getApp().getJobQueue ().addJob (jtWRITE, "HashedObject::store",
getApp().getJobQueue ().addJob (jtWRITE, "NodeObject::store",
BIND_TYPE (&HashedObjectStore::bulkWriteSQLite, this, P_1));
}
}
// else
// WriteLog (lsTRACE, HashedObject) << "HOS: already had " << hash;
// WriteLog (lsTRACE, NodeObject) << "HOS: already had " << hash;
mNegativeCache.del (hash);
return true;
@@ -274,7 +274,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
while (1)
{
std::vector< boost::shared_ptr<HashedObject> > set;
std::vector< boost::shared_ptr<NodeObject> > set;
set.reserve (128);
{
@@ -294,7 +294,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
mWriteLoad = std::max (setSize, static_cast<int> (mWriteSet.size ()));
setSize = set.size ();
}
// WriteLog (lsTRACE, HashedObject) << "HOS: writing " << set.size();
// WriteLog (lsTRACE, NodeObject) << "HOS: writing " << set.size();
#ifndef NO_SQLITE3_PREPARE
@@ -316,7 +316,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
pStB.step ();
pStB.reset ();
BOOST_FOREACH (const boost::shared_ptr<HashedObject>& it, set)
BOOST_FOREACH (const boost::shared_ptr<NodeObject>& it, set)
{
const char* type;
@@ -350,7 +350,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
if (!pSt.isDone (ret))
{
WriteLog (lsFATAL, HashedObject) << "Error saving hashed object " << ret;
WriteLog (lsFATAL, NodeObject) << "Error saving hashed object " << ret;
assert (false);
}
@@ -373,7 +373,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
db->executeSQL ("BEGIN TRANSACTION;");
BOOST_FOREACH (const boost::shared_ptr<HashedObject>& it, set)
BOOST_FOREACH (const boost::shared_ptr<NodeObject>& it, set)
{
char type;
@@ -410,9 +410,9 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
}
}
HashedObject::pointer HashedObjectStore::retrieveSQLite (uint256 const& hash)
NodeObject::pointer HashedObjectStore::retrieveSQLite (uint256 const& hash)
{
HashedObject::pointer obj = mCache.fetch (hash);
NodeObject::pointer obj = mCache.fetch (hash);
if (obj)
return obj;
@@ -452,7 +452,7 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite (uint256 const& hash)
{
pSt.reset ();
mNegativeCache.add (hash);
WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " fetch: not in db";
WriteLog (lsTRACE, NodeObject) << "HOS: " << hash << " fetch: not in db";
return obj;
}
@@ -494,7 +494,7 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite (uint256 const& hash)
assert (Serializer::getSHA512Half (data) == hash);
#endif
HashedObjectType htype = hotUNKNOWN;
NodeObjectType htype = hotUNKNOWN;
switch (type[0])
{
@@ -516,24 +516,24 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite (uint256 const& hash)
default:
assert (false);
WriteLog (lsERROR, HashedObject) << "Invalid hashed object";
WriteLog (lsERROR, NodeObject) << "Invalid hashed object";
mNegativeCache.add (hash);
return obj;
}
obj = boost::make_shared<HashedObject> (htype, index, data, hash);
obj = boost::make_shared<NodeObject> (htype, index, data, hash);
mCache.canonicalize (hash, obj);
if (mEphemeralDB)
LLWrite (obj, getApp().getEphemeralLDB ());
WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " fetch: in db";
WriteLog (lsTRACE, NodeObject) << "HOS: " << hash << " fetch: in db";
return obj;
}
int HashedObjectStore::import (const std::string& file)
{
WriteLog (lsWARNING, HashedObject) << "Hashed object import from \"" << file << "\".";
WriteLog (lsWARNING, NodeObject) << "Hashed object import from \"" << file << "\".";
UPTR_T<Database> importDB (new SqliteDatabase (file.c_str ()));
importDB->connect ();
@@ -551,7 +551,7 @@ int HashedObjectStore::import (const std::string& file)
if (hash.isZero ())
{
WriteLog (lsWARNING, HashedObject) << "zero hash found in import table";
WriteLog (lsWARNING, NodeObject) << "zero hash found in import table";
}
else
{
@@ -568,7 +568,7 @@ int HashedObjectStore::import (const std::string& file)
std::string type;
importDB->getStr ("ObjType", type);
HashedObjectType htype = hotUNKNOWN;
NodeObjectType htype = hotUNKNOWN;
switch (type[0])
{
@@ -590,7 +590,7 @@ int HashedObjectStore::import (const std::string& file)
default:
assert (false);
WriteLog (lsERROR, HashedObject) << "Invalid hashed object";
WriteLog (lsERROR, NodeObject) << "Invalid hashed object";
}
* (bufPtr + 8) = static_cast<unsigned char> (htype);
@@ -601,7 +601,7 @@ int HashedObjectStore::import (const std::string& file)
if (!st.ok ())
{
WriteLog (lsFATAL, HashedObject) << "Failed to store hash node";
WriteLog (lsFATAL, NodeObject) << "Failed to store hash node";
assert (false);
}
@@ -610,11 +610,11 @@ int HashedObjectStore::import (const std::string& file)
if ((count % 10000) == 0)
{
WriteLog (lsINFO, HashedObject) << "Import in progress: " << count;
WriteLog (lsINFO, NodeObject) << "Import in progress: " << count;
}
}
WriteLog (lsWARNING, HashedObject) << "Imported " << count << " nodes";
WriteLog (lsWARNING, NodeObject) << "Imported " << count << " nodes";
return count;
}

View File

@@ -25,7 +25,7 @@ public:
return mCache.getHitRate ();
}
bool store (HashedObjectType type, uint32 index, Blob const& data,
bool store (NodeObjectType type, uint32 index, Blob const& data,
uint256 const& hash)
{
if (mLevelDB)
@@ -34,7 +34,7 @@ public:
return storeSQLite (type, index, data, hash);
}
HashedObject::pointer retrieve (uint256 const& hash)
NodeObject::pointer retrieve (uint256 const& hash)
{
if (mLevelDB)
return retrieveLevelDB (hash);
@@ -42,14 +42,14 @@ public:
return retrieveSQLite (hash);
}
bool storeSQLite (HashedObjectType type, uint32 index, Blob const& data,
bool storeSQLite (NodeObjectType type, uint32 index, Blob const& data,
uint256 const& hash);
HashedObject::pointer retrieveSQLite (uint256 const& hash);
NodeObject::pointer retrieveSQLite (uint256 const& hash);
void bulkWriteSQLite (Job&);
bool storeLevelDB (HashedObjectType type, uint32 index, Blob const& data,
bool storeLevelDB (NodeObjectType type, uint32 index, Blob const& data,
uint256 const& hash);
HashedObject::pointer retrieveLevelDB (uint256 const& hash);
NodeObject::pointer retrieveLevelDB (uint256 const& hash);
void bulkWriteLevelDB (Job&);
@@ -65,12 +65,12 @@ public:
int import (const std::string& fileName);
private:
static HashedObject::pointer LLRetrieve (uint256 const& hash, leveldb::DB* db);
static void LLWrite (boost::shared_ptr<HashedObject> ptr, leveldb::DB* db);
static void LLWrite (const std::vector< boost::shared_ptr<HashedObject> >& set, leveldb::DB* db);
static NodeObject::pointer LLRetrieve (uint256 const& hash, leveldb::DB* db);
static void LLWrite (boost::shared_ptr<NodeObject> ptr, leveldb::DB* db);
static void LLWrite (const std::vector< boost::shared_ptr<NodeObject> >& set, leveldb::DB* db);
private:
TaggedCache<uint256, HashedObject, UptimeTimerAdapter> mCache;
TaggedCache<uint256, NodeObject, UptimeTimerAdapter> mCache;
KeyCache <uint256, UptimeTimerAdapter> mNegativeCache;
boost::mutex mWriteMutex;
@@ -78,7 +78,7 @@ private:
int mWriteGeneration;
int mWriteLoad;
std::vector< boost::shared_ptr<HashedObject> > mWriteSet;
std::vector< boost::shared_ptr<NodeObject> > mWriteSet;
bool mWritePending;
bool mLevelDB;
bool mEphemeralDB;

View File

@@ -4,10 +4,10 @@
*/
//==============================================================================
SETUP_LOG (HashedObject)
SETUP_LOG (NodeObject)
HashedObject::HashedObject (
HashedObjectType type,
NodeObject::NodeObject (
NodeObjectType type,
LedgerIndex ledgerIndex,
Blob const& binaryDataToCopy,
uint256 const& hash)
@@ -18,8 +18,8 @@ HashedObject::HashedObject (
{
}
HashedObject::HashedObject (
HashedObjectType type,
NodeObject::NodeObject (
NodeObjectType type,
LedgerIndex ledgerIndex,
void const* bufferToCopy,
int bytesInBuffer,
@@ -32,22 +32,22 @@ HashedObject::HashedObject (
{
}
HashedObjectType HashedObject::getType () const
NodeObjectType NodeObject::getType () const
{
return mType;
}
uint256 const& HashedObject::getHash () const
uint256 const& NodeObject::getHash () const
{
return mHash;
}
LedgerIndex HashedObject::getIndex () const
LedgerIndex NodeObject::getIndex () const
{
return mLedgerIndex;
}
Blob const& HashedObject::getData () const
Blob const& NodeObject::getData () const
{
return mData;
}

View File

@@ -9,7 +9,7 @@
/** The types of hashed objects.
*/
enum HashedObjectType
enum NodeObjectType
{
hotUNKNOWN = 0,
hotLEDGER = 1,
@@ -32,20 +32,20 @@ enum HashedObjectType
// VFALCO TODO consider making the instance a private member of SHAMap
// since its the primary user.
//
class HashedObject
: public CountedObject <HashedObject>
class NodeObject
: public CountedObject <NodeObject>
{
public:
static char const* getCountedObjectName () { return "HashedObject"; }
static char const* getCountedObjectName () { return "NodeObject"; }
typedef boost::shared_ptr <HashedObject> pointer;
typedef boost::shared_ptr <NodeObject> pointer;
typedef pointer const& ref;
/** Create from a vector of data.
@note A copy of the data is created.
*/
HashedObject (HashedObjectType type,
NodeObject (NodeObjectType type,
LedgerIndex ledgerIndex,
Blob const & binaryDataToCopy,
uint256 const & hash);
@@ -54,7 +54,7 @@ public:
@note A copy of the data is created.
*/
HashedObject (HashedObjectType type,
NodeObject (NodeObjectType type,
LedgerIndex ledgerIndex,
void const * bufferToCopy,
int bytesInBuffer,
@@ -62,7 +62,7 @@ public:
/** Retrieve the type of this object.
*/
HashedObjectType getType () const;
NodeObjectType getType () const;
/** Retrieve the hash metadata.
*/
@@ -78,7 +78,7 @@ public:
Blob const& getData () const;
private:
HashedObjectType const mType;
NodeObjectType const mType;
uint256 const mHash;
LedgerIndex const mLedgerIndex;
Blob const mData;

View File

@@ -94,7 +94,7 @@ namespace ripple
#include "src/cpp/ripple/ripple_SqliteDatabase.h"
#include "src/cpp/ripple/ripple_DBInit.h"
#include "node/ripple_HashedObject.h"
#include "node/ripple_NodeObject.h"
#include "node/ripple_HashedObjectStore.h"
#include "node/ripple_HashStoreBE.h"
#include "node/ripple_HSBELevelDB.h"
@@ -235,7 +235,7 @@ static const uint64 tenTo17m1 = tenTo17 - 1;
#if ! defined (RIPPLE_MAIN_PART) || RIPPLE_MAIN_PART == 1
#include "basics/ripple_RPCServerHandler.cpp"
#include "node/ripple_HashedObject.cpp"
#include "node/ripple_NodeObject.cpp"
#include "node/ripple_HashedObjectStore.cpp"
#include "node/ripple_HSBELevelDB.cpp"
#include "node/ripple_HSBESqlite.cpp"

View File

@@ -49,7 +49,7 @@ bool InboundLedger::tryLocal ()
if (!mHaveBase)
{
// Nothing we can do without the ledger base
HashedObject::pointer node = getApp().getHashedObjectStore ().retrieve (mHash);
NodeObject::pointer node = getApp().getHashedObjectStore ().retrieve (mHash);
if (!node)
{

View File

@@ -1535,7 +1535,7 @@ void PeerImp::recvGetObjectByHash (const boost::shared_ptr<protocol::TMGetObject
if (obj.has_hash () && (obj.hash ().size () == (256 / 8)))
{
memcpy (hash.begin (), obj.hash ().data (), 256 / 8);
HashedObject::pointer hObj = getApp().getHashedObjectStore ().retrieve (hash);
NodeObject::pointer hObj = getApp().getHashedObjectStore ().retrieve (hash);
if (hObj)
{

View File

@@ -824,7 +824,7 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternalNT (const SHAMapNode& id, uint2
if (!getApp().running ())
return ret;
HashedObject::pointer obj (getApp().getHashedObjectStore ().retrieve (hash));
NodeObject::pointer obj (getApp().getHashedObjectStore ().retrieve (hash));
if (!obj)
{
@@ -913,7 +913,7 @@ int SHAMap::armDirty ()
return ++mSeq;
}
int SHAMap::flushDirty (DirtyMap& map, int maxNodes, HashedObjectType t, uint32 seq)
int SHAMap::flushDirty (DirtyMap& map, int maxNodes, NodeObjectType t, uint32 seq)
{
int flushed = 0;
Serializer s;

View File

@@ -141,7 +141,7 @@ public:
bool compare (SHAMap::ref otherMap, Delta & differences, int maxCount);
int armDirty ();
static int flushDirty (DirtyMap & dirtyMap, int maxNodes, HashedObjectType t, uint32 seq);
static int flushDirty (DirtyMap & dirtyMap, int maxNodes, NodeObjectType t, uint32 seq);
boost::shared_ptr<DirtyMap> disarmDirty ();
void setSeq (uint32 seq)