mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-22 12:05:53 +00:00
Rename to NodeObject
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</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)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">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_BuildVersion.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_RPCServerHandler.h" />
|
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_RPCServerHandler.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_app\basics\ripple_Version.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_HashedObjectStore.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HashStoreBE.h" />
|
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HashStoreBE.h" />
|
||||||
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HSBELevelDB.h" />
|
<ClInclude Include="..\..\modules\ripple_app\node\ripple_HSBELevelDB.h" />
|
||||||
|
|||||||
@@ -855,10 +855,10 @@
|
|||||||
<ClCompile Include="..\..\modules\ripple_app\node\ripple_HSBESqlite.cpp">
|
<ClCompile Include="..\..\modules\ripple_app\node\ripple_HSBESqlite.cpp">
|
||||||
<Filter>[1] Ripple\ripple_app\node</Filter>
|
<Filter>[1] Ripple\ripple_app\node</Filter>
|
||||||
</ClCompile>
|
</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>
|
<Filter>[1] Ripple\ripple_app\node</Filter>
|
||||||
</ClCompile>
|
</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>
|
<Filter>[1] Ripple\ripple_app\node</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -1605,10 +1605,10 @@
|
|||||||
<ClInclude Include="..\..\src\cpp\ripple\ripple_DBInit.h">
|
<ClInclude Include="..\..\src\cpp\ripple\ripple_DBInit.h">
|
||||||
<Filter>[1] Ripple\ripple_app\_data</Filter>
|
<Filter>[1] Ripple\ripple_app\_data</Filter>
|
||||||
</ClInclude>
|
</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>
|
<Filter>[1] Ripple\ripple_app\node</Filter>
|
||||||
</ClInclude>
|
</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>
|
<Filter>[1] Ripple\ripple_app\node</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ std::string HSBELevelDB::getDataBaseName()
|
|||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HSBELevelDB::store(HashedObject::ref obj)
|
bool HSBELevelDB::store(NodeObject::ref obj)
|
||||||
{
|
{
|
||||||
Blob blob (toBlob (obj));
|
Blob blob (toBlob (obj));
|
||||||
return mDB->Put (leveldb::WriteOptions (),
|
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 ();
|
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;
|
leveldb::WriteBatch batch;
|
||||||
|
|
||||||
BOOST_FOREACH (HashedObject::ref obj, objs)
|
BOOST_FOREACH (NodeObject::ref obj, objs)
|
||||||
{
|
{
|
||||||
Blob blob (toBlob (obj));
|
Blob blob (toBlob (obj));
|
||||||
batch.Put (
|
batch.Put (
|
||||||
@@ -45,18 +45,18 @@ bool HSBELevelDB::bulkStore(const std::vector< HashedObject::pointer >& objs)
|
|||||||
return mDB->Write (leveldb::WriteOptions (), &batch).ok ();
|
return mDB->Write (leveldb::WriteOptions (), &batch).ok ();
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedObject::pointer HSBELevelDB::retrieve(uint256 const& hash)
|
NodeObject::pointer HSBELevelDB::retrieve(uint256 const& hash)
|
||||||
{
|
{
|
||||||
std::string sData;
|
std::string sData;
|
||||||
if (!mDB->Get (leveldb::ReadOptions (),
|
if (!mDB->Get (leveldb::ReadOptions (),
|
||||||
leveldb::Slice (reinterpret_cast<char const*>(hash.begin ()), 256 / 8), &sData).ok ())
|
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 ());
|
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 ());
|
leveldb::Iterator* it = mDB->NewIterator (leveldb::ReadOptions ());
|
||||||
for (it->SeekToFirst (); it->Valid (); it->Next ())
|
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 ());
|
Blob rawData (9 + obj->getData ().size ());
|
||||||
unsigned char* bufPtr = &rawData.front();
|
unsigned char* bufPtr = &rawData.front();
|
||||||
@@ -83,7 +83,7 @@ Blob HSBELevelDB::toBlob(HashedObject::ref obj)
|
|||||||
return rawData;
|
return rawData;
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedObject::pointer HSBELevelDB::fromBinary(uint256 const& hash,
|
NodeObject::pointer HSBELevelDB::fromBinary(uint256 const& hash,
|
||||||
char const* data, int size)
|
char const* data, int size)
|
||||||
{
|
{
|
||||||
if (size < 9)
|
if (size < 9)
|
||||||
@@ -92,6 +92,6 @@ HashedObject::pointer HSBELevelDB::fromBinary(uint256 const& hash,
|
|||||||
uint32 index = htonl (*reinterpret_cast<const uint32*> (data));
|
uint32 index = htonl (*reinterpret_cast<const uint32*> (data));
|
||||||
int htype = data[8];
|
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);
|
data + 9, size - 9, hash);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,19 +14,19 @@ public:
|
|||||||
|
|
||||||
std::string getDataBaseName();
|
std::string getDataBaseName();
|
||||||
|
|
||||||
bool store(HashedObject::ref);
|
bool store(NodeObject::ref);
|
||||||
bool bulkStore(const std::vector< HashedObject::pointer >&);
|
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:
|
private:
|
||||||
std::string mName;
|
std::string mName;
|
||||||
leveldb::DB* mDB;
|
leveldb::DB* mDB;
|
||||||
|
|
||||||
Blob toBlob(HashedObject::ref);
|
Blob toBlob(NodeObject::ref);
|
||||||
HashedObject::pointer fromBinary(uint256 const& hash, char const* data, int size);
|
NodeObject::pointer fromBinary(uint256 const& hash, char const* data, int size);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ std::string HSBESQLite::getDataBaseName()
|
|||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HSBESQLite::store(HashedObject::ref object)
|
bool HSBESQLite::store(NodeObject::ref object)
|
||||||
{
|
{
|
||||||
ScopedLock sl(mDb->getDBLock());
|
ScopedLock sl(mDb->getDBLock());
|
||||||
static SqliteStatement pSt(mDb->getDB()->getSqliteDB(),
|
static SqliteStatement pSt(mDb->getDB()->getSqliteDB(),
|
||||||
@@ -28,7 +28,7 @@ bool HSBESQLite::store(HashedObject::ref object)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HSBESQLite::bulkStore(const std::vector< HashedObject::pointer >& objects)
|
bool HSBESQLite::bulkStore(const std::vector< NodeObject::pointer >& objects)
|
||||||
{
|
{
|
||||||
ScopedLock sl(mDb->getDBLock());
|
ScopedLock sl(mDb->getDBLock());
|
||||||
static SqliteStatement pStB(mDb->getDB()->getSqliteDB(), "BEGIN TRANSACTION;");
|
static SqliteStatement pStB(mDb->getDB()->getSqliteDB(), "BEGIN TRANSACTION;");
|
||||||
@@ -40,7 +40,7 @@ bool HSBESQLite::bulkStore(const std::vector< HashedObject::pointer >& objects)
|
|||||||
pStB.step();
|
pStB.step();
|
||||||
pStB.reset();
|
pStB.reset();
|
||||||
|
|
||||||
BOOST_FOREACH(HashedObject::ref object, objects)
|
BOOST_FOREACH(NodeObject::ref object, objects)
|
||||||
{
|
{
|
||||||
bind(pSt, object);
|
bind(pSt, object);
|
||||||
pSt.step();
|
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());
|
ScopedLock sl(mDb->getDBLock());
|
||||||
@@ -66,7 +66,7 @@ HashedObject::pointer HSBESQLite::retrieve(uint256 const& hash)
|
|||||||
pSt.bind(1, hash.GetHex());
|
pSt.bind(1, hash.GetHex());
|
||||||
|
|
||||||
if (pSt.isRow(pSt.step()))
|
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();
|
pSt.reset();
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ HashedObject::pointer HSBESQLite::retrieve(uint256 const& hash)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HSBESQLite::visitAll(FUNCTION_TYPE<void (HashedObject::pointer)> func)
|
void HSBESQLite::visitAll(FUNCTION_TYPE<void (NodeObject::pointer)> func)
|
||||||
{
|
{
|
||||||
uint256 hash;
|
uint256 hash;
|
||||||
|
|
||||||
@@ -84,13 +84,13 @@ void HSBESQLite::visitAll(FUNCTION_TYPE<void (HashedObject::pointer)> func)
|
|||||||
while (pSt.isRow(pSt.step()))
|
while (pSt.isRow(pSt.step()))
|
||||||
{
|
{
|
||||||
hash.SetHexExact(pSt.getString(3));
|
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();
|
pSt.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HSBESQLite::bind(SqliteStatement& statement, HashedObject::ref object)
|
void HSBESQLite::bind(SqliteStatement& statement, NodeObject::ref object)
|
||||||
{
|
{
|
||||||
char const* type;
|
char const* type;
|
||||||
switch (object->getType())
|
switch (object->getType())
|
||||||
@@ -108,9 +108,9 @@ void HSBESQLite::bind(SqliteStatement& statement, HashedObject::ref object)
|
|||||||
statement.bindStatic(4, object->getData());
|
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())
|
if (!type.empty())
|
||||||
{
|
{
|
||||||
switch (type[0])
|
switch (type[0])
|
||||||
|
|||||||
@@ -14,19 +14,19 @@ public:
|
|||||||
|
|
||||||
std::string getDataBaseName();
|
std::string getDataBaseName();
|
||||||
|
|
||||||
bool store(HashedObject::ref);
|
bool store(NodeObject::ref);
|
||||||
bool bulkStore(const std::vector< HashedObject::pointer >&);
|
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:
|
private:
|
||||||
std::string mName;
|
std::string mName;
|
||||||
DatabaseCon* mDb;
|
DatabaseCon* mDb;
|
||||||
|
|
||||||
void bind(SqliteStatement& statement, HashedObject::ref object);
|
void bind(SqliteStatement& statement, NodeObject::ref object);
|
||||||
HashedObjectType getType(std::string const&);
|
NodeObjectType getType(std::string const&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -16,16 +16,16 @@ public:
|
|||||||
|
|
||||||
// Store/retrieve a single object
|
// Store/retrieve a single object
|
||||||
// These functions must be thread safe
|
// These functions must be thread safe
|
||||||
virtual bool store(HashedObject::ref) = 0;
|
virtual bool store(NodeObject::ref) = 0;
|
||||||
virtual HashedObject::pointer retrieve(uint256 const &hash) = 0;
|
virtual NodeObject::pointer retrieve(uint256 const &hash) = 0;
|
||||||
|
|
||||||
// Store a group of objects
|
// Store a group of objects
|
||||||
// This function will only be called from a single thread
|
// 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
|
// Visit every object in the database
|
||||||
// This function will only be called during an import operation
|
// 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
|
#endif
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ HashedObjectStore::HashedObjectStore (int cacheSize, int cacheAge) :
|
|||||||
mLevelDB = false;
|
mLevelDB = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteLog (lsFATAL, HashedObject) << "Incorrect database selection";
|
WriteLog (lsFATAL, NodeObject) << "Incorrect database selection";
|
||||||
assert (false);
|
assert (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ int HashedObjectStore::getWriteLoad ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// low-level retrieve
|
// 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;
|
std::string sData;
|
||||||
|
|
||||||
@@ -56,21 +56,21 @@ HashedObject::pointer HashedObjectStore::LLRetrieve (uint256 const& hash, leveld
|
|||||||
if (!st.ok ())
|
if (!st.ok ())
|
||||||
{
|
{
|
||||||
assert (st.IsNotFound ());
|
assert (st.IsNotFound ());
|
||||||
return HashedObject::pointer ();
|
return NodeObject::pointer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char* bufPtr = reinterpret_cast<const unsigned char*> (&sData[0]);
|
const unsigned char* bufPtr = reinterpret_cast<const unsigned char*> (&sData[0]);
|
||||||
uint32 index = htonl (*reinterpret_cast<const uint32*> (bufPtr));
|
uint32 index = htonl (*reinterpret_cast<const uint32*> (bufPtr));
|
||||||
int htype = bufPtr[8];
|
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);
|
bufPtr + 9, sData.size () - 9, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
// low-level write single
|
// 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 ());
|
Blob rawData (9 + obj.getData ().size ());
|
||||||
unsigned char* bufPtr = &rawData.front ();
|
unsigned char* bufPtr = &rawData.front ();
|
||||||
|
|
||||||
@@ -85,19 +85,19 @@ void HashedObjectStore::LLWrite (boost::shared_ptr<HashedObject> ptr, leveldb::D
|
|||||||
|
|
||||||
if (!st.ok ())
|
if (!st.ok ())
|
||||||
{
|
{
|
||||||
WriteLog (lsFATAL, HashedObject) << "Failed to store hash node";
|
WriteLog (lsFATAL, NodeObject) << "Failed to store hash node";
|
||||||
assert (false);
|
assert (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// low-level write set
|
// 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;
|
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 ());
|
Blob rawData (9 + obj.getData ().size ());
|
||||||
unsigned char* bufPtr = &rawData.front ();
|
unsigned char* bufPtr = &rawData.front ();
|
||||||
|
|
||||||
@@ -114,12 +114,12 @@ void HashedObjectStore::LLWrite (const std::vector< boost::shared_ptr<HashedObje
|
|||||||
|
|
||||||
if (!st.ok ())
|
if (!st.ok ())
|
||||||
{
|
{
|
||||||
WriteLog (lsFATAL, HashedObject) << "Failed to store hash node";
|
WriteLog (lsFATAL, NodeObject) << "Failed to store hash node";
|
||||||
assert (false);
|
assert (false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HashedObjectStore::storeLevelDB (HashedObjectType type, uint32 index,
|
bool HashedObjectStore::storeLevelDB (NodeObjectType type, uint32 index,
|
||||||
Blob const& data, uint256 const& hash)
|
Blob const& data, uint256 const& hash)
|
||||||
{
|
{
|
||||||
// return: false = already in cache, true = added to cache
|
// 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));
|
assert (hash == Serializer::getSHA512Half (data));
|
||||||
#endif
|
#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))
|
if (!mCache.canonicalize (hash, object))
|
||||||
{
|
{
|
||||||
@@ -143,7 +143,7 @@ bool HashedObjectStore::storeLevelDB (HashedObjectType type, uint32 index,
|
|||||||
if (!mWritePending)
|
if (!mWritePending)
|
||||||
{
|
{
|
||||||
mWritePending = true;
|
mWritePending = true;
|
||||||
getApp().getJobQueue ().addJob (jtWRITE, "HashedObject::store",
|
getApp().getJobQueue ().addJob (jtWRITE, "NodeObject::store",
|
||||||
BIND_TYPE (&HashedObjectStore::bulkWriteLevelDB, this, P_1));
|
BIND_TYPE (&HashedObjectStore::bulkWriteLevelDB, this, P_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,7 +159,7 @@ void HashedObjectStore::bulkWriteLevelDB (Job&)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
std::vector< boost::shared_ptr<HashedObject> > set;
|
std::vector< boost::shared_ptr<NodeObject> > set;
|
||||||
set.reserve (128);
|
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 ())
|
if (obj || mNegativeCache.isPresent (hash) || !getApp().getHashNodeLDB ())
|
||||||
return obj;
|
return obj;
|
||||||
@@ -222,46 +222,46 @@ HashedObject::pointer HashedObjectStore::retrieveLevelDB (uint256 const& hash)
|
|||||||
if (mEphemeralDB)
|
if (mEphemeralDB)
|
||||||
LLWrite (obj, getApp().getEphemeralLDB ());
|
LLWrite (obj, getApp().getEphemeralLDB ());
|
||||||
|
|
||||||
WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " fetch: in db";
|
WriteLog (lsTRACE, NodeObject) << "HOS: " << hash << " fetch: in db";
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HashedObjectStore::storeSQLite (HashedObjectType type, uint32 index,
|
bool HashedObjectStore::storeSQLite (NodeObjectType type, uint32 index,
|
||||||
Blob const& data, uint256 const& hash)
|
Blob const& data, uint256 const& hash)
|
||||||
{
|
{
|
||||||
// return: false = already in cache, true = added to cache
|
// return: false = already in cache, true = added to cache
|
||||||
if (!getApp().getHashNodeDB ())
|
if (!getApp().getHashNodeDB ())
|
||||||
{
|
{
|
||||||
WriteLog (lsTRACE, HashedObject) << "HOS: no db";
|
WriteLog (lsTRACE, NodeObject) << "HOS: no db";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCache.touch (hash))
|
if (mCache.touch (hash))
|
||||||
{
|
{
|
||||||
WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " store: incache";
|
WriteLog (lsTRACE, NodeObject) << "HOS: " << hash << " store: incache";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (hash == Serializer::getSHA512Half (data));
|
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))
|
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);
|
boost::mutex::scoped_lock sl (mWriteMutex);
|
||||||
mWriteSet.push_back (object);
|
mWriteSet.push_back (object);
|
||||||
|
|
||||||
if (!mWritePending)
|
if (!mWritePending)
|
||||||
{
|
{
|
||||||
mWritePending = true;
|
mWritePending = true;
|
||||||
getApp().getJobQueue ().addJob (jtWRITE, "HashedObject::store",
|
getApp().getJobQueue ().addJob (jtWRITE, "NodeObject::store",
|
||||||
BIND_TYPE (&HashedObjectStore::bulkWriteSQLite, this, P_1));
|
BIND_TYPE (&HashedObjectStore::bulkWriteSQLite, this, P_1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// else
|
// else
|
||||||
// WriteLog (lsTRACE, HashedObject) << "HOS: already had " << hash;
|
// WriteLog (lsTRACE, NodeObject) << "HOS: already had " << hash;
|
||||||
mNegativeCache.del (hash);
|
mNegativeCache.del (hash);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -274,7 +274,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
std::vector< boost::shared_ptr<HashedObject> > set;
|
std::vector< boost::shared_ptr<NodeObject> > set;
|
||||||
set.reserve (128);
|
set.reserve (128);
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -294,7 +294,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
|
|||||||
mWriteLoad = std::max (setSize, static_cast<int> (mWriteSet.size ()));
|
mWriteLoad = std::max (setSize, static_cast<int> (mWriteSet.size ()));
|
||||||
setSize = set.size ();
|
setSize = set.size ();
|
||||||
}
|
}
|
||||||
// WriteLog (lsTRACE, HashedObject) << "HOS: writing " << set.size();
|
// WriteLog (lsTRACE, NodeObject) << "HOS: writing " << set.size();
|
||||||
|
|
||||||
#ifndef NO_SQLITE3_PREPARE
|
#ifndef NO_SQLITE3_PREPARE
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
|
|||||||
pStB.step ();
|
pStB.step ();
|
||||||
pStB.reset ();
|
pStB.reset ();
|
||||||
|
|
||||||
BOOST_FOREACH (const boost::shared_ptr<HashedObject>& it, set)
|
BOOST_FOREACH (const boost::shared_ptr<NodeObject>& it, set)
|
||||||
{
|
{
|
||||||
const char* type;
|
const char* type;
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
|
|||||||
|
|
||||||
if (!pSt.isDone (ret))
|
if (!pSt.isDone (ret))
|
||||||
{
|
{
|
||||||
WriteLog (lsFATAL, HashedObject) << "Error saving hashed object " << ret;
|
WriteLog (lsFATAL, NodeObject) << "Error saving hashed object " << ret;
|
||||||
assert (false);
|
assert (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ void HashedObjectStore::bulkWriteSQLite (Job&)
|
|||||||
|
|
||||||
db->executeSQL ("BEGIN TRANSACTION;");
|
db->executeSQL ("BEGIN TRANSACTION;");
|
||||||
|
|
||||||
BOOST_FOREACH (const boost::shared_ptr<HashedObject>& it, set)
|
BOOST_FOREACH (const boost::shared_ptr<NodeObject>& it, set)
|
||||||
{
|
{
|
||||||
char type;
|
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)
|
if (obj)
|
||||||
return obj;
|
return obj;
|
||||||
@@ -452,7 +452,7 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite (uint256 const& hash)
|
|||||||
{
|
{
|
||||||
pSt.reset ();
|
pSt.reset ();
|
||||||
mNegativeCache.add (hash);
|
mNegativeCache.add (hash);
|
||||||
WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " fetch: not in db";
|
WriteLog (lsTRACE, NodeObject) << "HOS: " << hash << " fetch: not in db";
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,7 +494,7 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite (uint256 const& hash)
|
|||||||
assert (Serializer::getSHA512Half (data) == hash);
|
assert (Serializer::getSHA512Half (data) == hash);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HashedObjectType htype = hotUNKNOWN;
|
NodeObjectType htype = hotUNKNOWN;
|
||||||
|
|
||||||
switch (type[0])
|
switch (type[0])
|
||||||
{
|
{
|
||||||
@@ -516,24 +516,24 @@ HashedObject::pointer HashedObjectStore::retrieveSQLite (uint256 const& hash)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
assert (false);
|
assert (false);
|
||||||
WriteLog (lsERROR, HashedObject) << "Invalid hashed object";
|
WriteLog (lsERROR, NodeObject) << "Invalid hashed object";
|
||||||
mNegativeCache.add (hash);
|
mNegativeCache.add (hash);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = boost::make_shared<HashedObject> (htype, index, data, hash);
|
obj = boost::make_shared<NodeObject> (htype, index, data, hash);
|
||||||
mCache.canonicalize (hash, obj);
|
mCache.canonicalize (hash, obj);
|
||||||
|
|
||||||
if (mEphemeralDB)
|
if (mEphemeralDB)
|
||||||
LLWrite (obj, getApp().getEphemeralLDB ());
|
LLWrite (obj, getApp().getEphemeralLDB ());
|
||||||
|
|
||||||
WriteLog (lsTRACE, HashedObject) << "HOS: " << hash << " fetch: in db";
|
WriteLog (lsTRACE, NodeObject) << "HOS: " << hash << " fetch: in db";
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
int HashedObjectStore::import (const std::string& file)
|
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 ()));
|
UPTR_T<Database> importDB (new SqliteDatabase (file.c_str ()));
|
||||||
importDB->connect ();
|
importDB->connect ();
|
||||||
|
|
||||||
@@ -551,7 +551,7 @@ int HashedObjectStore::import (const std::string& file)
|
|||||||
|
|
||||||
if (hash.isZero ())
|
if (hash.isZero ())
|
||||||
{
|
{
|
||||||
WriteLog (lsWARNING, HashedObject) << "zero hash found in import table";
|
WriteLog (lsWARNING, NodeObject) << "zero hash found in import table";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -568,7 +568,7 @@ int HashedObjectStore::import (const std::string& file)
|
|||||||
|
|
||||||
std::string type;
|
std::string type;
|
||||||
importDB->getStr ("ObjType", type);
|
importDB->getStr ("ObjType", type);
|
||||||
HashedObjectType htype = hotUNKNOWN;
|
NodeObjectType htype = hotUNKNOWN;
|
||||||
|
|
||||||
switch (type[0])
|
switch (type[0])
|
||||||
{
|
{
|
||||||
@@ -590,7 +590,7 @@ int HashedObjectStore::import (const std::string& file)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
assert (false);
|
assert (false);
|
||||||
WriteLog (lsERROR, HashedObject) << "Invalid hashed object";
|
WriteLog (lsERROR, NodeObject) << "Invalid hashed object";
|
||||||
}
|
}
|
||||||
|
|
||||||
* (bufPtr + 8) = static_cast<unsigned char> (htype);
|
* (bufPtr + 8) = static_cast<unsigned char> (htype);
|
||||||
@@ -601,7 +601,7 @@ int HashedObjectStore::import (const std::string& file)
|
|||||||
|
|
||||||
if (!st.ok ())
|
if (!st.ok ())
|
||||||
{
|
{
|
||||||
WriteLog (lsFATAL, HashedObject) << "Failed to store hash node";
|
WriteLog (lsFATAL, NodeObject) << "Failed to store hash node";
|
||||||
assert (false);
|
assert (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -610,11 +610,11 @@ int HashedObjectStore::import (const std::string& file)
|
|||||||
|
|
||||||
if ((count % 10000) == 0)
|
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;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
return mCache.getHitRate ();
|
return mCache.getHitRate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool store (HashedObjectType type, uint32 index, Blob const& data,
|
bool store (NodeObjectType type, uint32 index, Blob const& data,
|
||||||
uint256 const& hash)
|
uint256 const& hash)
|
||||||
{
|
{
|
||||||
if (mLevelDB)
|
if (mLevelDB)
|
||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
return storeSQLite (type, index, data, hash);
|
return storeSQLite (type, index, data, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedObject::pointer retrieve (uint256 const& hash)
|
NodeObject::pointer retrieve (uint256 const& hash)
|
||||||
{
|
{
|
||||||
if (mLevelDB)
|
if (mLevelDB)
|
||||||
return retrieveLevelDB (hash);
|
return retrieveLevelDB (hash);
|
||||||
@@ -42,14 +42,14 @@ public:
|
|||||||
return retrieveSQLite (hash);
|
return retrieveSQLite (hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool storeSQLite (HashedObjectType type, uint32 index, Blob const& data,
|
bool storeSQLite (NodeObjectType type, uint32 index, Blob const& data,
|
||||||
uint256 const& hash);
|
uint256 const& hash);
|
||||||
HashedObject::pointer retrieveSQLite (uint256 const& hash);
|
NodeObject::pointer retrieveSQLite (uint256 const& hash);
|
||||||
void bulkWriteSQLite (Job&);
|
void bulkWriteSQLite (Job&);
|
||||||
|
|
||||||
bool storeLevelDB (HashedObjectType type, uint32 index, Blob const& data,
|
bool storeLevelDB (NodeObjectType type, uint32 index, Blob const& data,
|
||||||
uint256 const& hash);
|
uint256 const& hash);
|
||||||
HashedObject::pointer retrieveLevelDB (uint256 const& hash);
|
NodeObject::pointer retrieveLevelDB (uint256 const& hash);
|
||||||
void bulkWriteLevelDB (Job&);
|
void bulkWriteLevelDB (Job&);
|
||||||
|
|
||||||
|
|
||||||
@@ -65,12 +65,12 @@ public:
|
|||||||
int import (const std::string& fileName);
|
int import (const std::string& fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static HashedObject::pointer LLRetrieve (uint256 const& hash, leveldb::DB* db);
|
static NodeObject::pointer LLRetrieve (uint256 const& hash, leveldb::DB* db);
|
||||||
static void LLWrite (boost::shared_ptr<HashedObject> ptr, leveldb::DB* db);
|
static void LLWrite (boost::shared_ptr<NodeObject> ptr, leveldb::DB* db);
|
||||||
static void LLWrite (const std::vector< boost::shared_ptr<HashedObject> >& set, leveldb::DB* db);
|
static void LLWrite (const std::vector< boost::shared_ptr<NodeObject> >& set, leveldb::DB* db);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TaggedCache<uint256, HashedObject, UptimeTimerAdapter> mCache;
|
TaggedCache<uint256, NodeObject, UptimeTimerAdapter> mCache;
|
||||||
KeyCache <uint256, UptimeTimerAdapter> mNegativeCache;
|
KeyCache <uint256, UptimeTimerAdapter> mNegativeCache;
|
||||||
|
|
||||||
boost::mutex mWriteMutex;
|
boost::mutex mWriteMutex;
|
||||||
@@ -78,7 +78,7 @@ private:
|
|||||||
int mWriteGeneration;
|
int mWriteGeneration;
|
||||||
int mWriteLoad;
|
int mWriteLoad;
|
||||||
|
|
||||||
std::vector< boost::shared_ptr<HashedObject> > mWriteSet;
|
std::vector< boost::shared_ptr<NodeObject> > mWriteSet;
|
||||||
bool mWritePending;
|
bool mWritePending;
|
||||||
bool mLevelDB;
|
bool mLevelDB;
|
||||||
bool mEphemeralDB;
|
bool mEphemeralDB;
|
||||||
|
|||||||
@@ -4,10 +4,10 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
SETUP_LOG (HashedObject)
|
SETUP_LOG (NodeObject)
|
||||||
|
|
||||||
HashedObject::HashedObject (
|
NodeObject::NodeObject (
|
||||||
HashedObjectType type,
|
NodeObjectType type,
|
||||||
LedgerIndex ledgerIndex,
|
LedgerIndex ledgerIndex,
|
||||||
Blob const& binaryDataToCopy,
|
Blob const& binaryDataToCopy,
|
||||||
uint256 const& hash)
|
uint256 const& hash)
|
||||||
@@ -18,8 +18,8 @@ HashedObject::HashedObject (
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedObject::HashedObject (
|
NodeObject::NodeObject (
|
||||||
HashedObjectType type,
|
NodeObjectType type,
|
||||||
LedgerIndex ledgerIndex,
|
LedgerIndex ledgerIndex,
|
||||||
void const* bufferToCopy,
|
void const* bufferToCopy,
|
||||||
int bytesInBuffer,
|
int bytesInBuffer,
|
||||||
@@ -32,22 +32,22 @@ HashedObject::HashedObject (
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedObjectType HashedObject::getType () const
|
NodeObjectType NodeObject::getType () const
|
||||||
{
|
{
|
||||||
return mType;
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 const& HashedObject::getHash () const
|
uint256 const& NodeObject::getHash () const
|
||||||
{
|
{
|
||||||
return mHash;
|
return mHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
LedgerIndex HashedObject::getIndex () const
|
LedgerIndex NodeObject::getIndex () const
|
||||||
{
|
{
|
||||||
return mLedgerIndex;
|
return mLedgerIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
Blob const& HashedObject::getData () const
|
Blob const& NodeObject::getData () const
|
||||||
{
|
{
|
||||||
return mData;
|
return mData;
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
/** The types of hashed objects.
|
/** The types of hashed objects.
|
||||||
*/
|
*/
|
||||||
enum HashedObjectType
|
enum NodeObjectType
|
||||||
{
|
{
|
||||||
hotUNKNOWN = 0,
|
hotUNKNOWN = 0,
|
||||||
hotLEDGER = 1,
|
hotLEDGER = 1,
|
||||||
@@ -32,20 +32,20 @@ enum HashedObjectType
|
|||||||
// VFALCO TODO consider making the instance a private member of SHAMap
|
// VFALCO TODO consider making the instance a private member of SHAMap
|
||||||
// since its the primary user.
|
// since its the primary user.
|
||||||
//
|
//
|
||||||
class HashedObject
|
class NodeObject
|
||||||
: public CountedObject <HashedObject>
|
: public CountedObject <NodeObject>
|
||||||
{
|
{
|
||||||
public:
|
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;
|
typedef pointer const& ref;
|
||||||
|
|
||||||
/** Create from a vector of data.
|
/** Create from a vector of data.
|
||||||
|
|
||||||
@note A copy of the data is created.
|
@note A copy of the data is created.
|
||||||
*/
|
*/
|
||||||
HashedObject (HashedObjectType type,
|
NodeObject (NodeObjectType type,
|
||||||
LedgerIndex ledgerIndex,
|
LedgerIndex ledgerIndex,
|
||||||
Blob const & binaryDataToCopy,
|
Blob const & binaryDataToCopy,
|
||||||
uint256 const & hash);
|
uint256 const & hash);
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
|
|
||||||
@note A copy of the data is created.
|
@note A copy of the data is created.
|
||||||
*/
|
*/
|
||||||
HashedObject (HashedObjectType type,
|
NodeObject (NodeObjectType type,
|
||||||
LedgerIndex ledgerIndex,
|
LedgerIndex ledgerIndex,
|
||||||
void const * bufferToCopy,
|
void const * bufferToCopy,
|
||||||
int bytesInBuffer,
|
int bytesInBuffer,
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
|
|
||||||
/** Retrieve the type of this object.
|
/** Retrieve the type of this object.
|
||||||
*/
|
*/
|
||||||
HashedObjectType getType () const;
|
NodeObjectType getType () const;
|
||||||
|
|
||||||
/** Retrieve the hash metadata.
|
/** Retrieve the hash metadata.
|
||||||
*/
|
*/
|
||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
Blob const& getData () const;
|
Blob const& getData () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HashedObjectType const mType;
|
NodeObjectType const mType;
|
||||||
uint256 const mHash;
|
uint256 const mHash;
|
||||||
LedgerIndex const mLedgerIndex;
|
LedgerIndex const mLedgerIndex;
|
||||||
Blob const mData;
|
Blob const mData;
|
||||||
@@ -94,7 +94,7 @@ namespace ripple
|
|||||||
#include "src/cpp/ripple/ripple_SqliteDatabase.h"
|
#include "src/cpp/ripple/ripple_SqliteDatabase.h"
|
||||||
#include "src/cpp/ripple/ripple_DBInit.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_HashedObjectStore.h"
|
||||||
#include "node/ripple_HashStoreBE.h"
|
#include "node/ripple_HashStoreBE.h"
|
||||||
#include "node/ripple_HSBELevelDB.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
|
#if ! defined (RIPPLE_MAIN_PART) || RIPPLE_MAIN_PART == 1
|
||||||
|
|
||||||
#include "basics/ripple_RPCServerHandler.cpp"
|
#include "basics/ripple_RPCServerHandler.cpp"
|
||||||
#include "node/ripple_HashedObject.cpp"
|
#include "node/ripple_NodeObject.cpp"
|
||||||
#include "node/ripple_HashedObjectStore.cpp"
|
#include "node/ripple_HashedObjectStore.cpp"
|
||||||
#include "node/ripple_HSBELevelDB.cpp"
|
#include "node/ripple_HSBELevelDB.cpp"
|
||||||
#include "node/ripple_HSBESqlite.cpp"
|
#include "node/ripple_HSBESqlite.cpp"
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ bool InboundLedger::tryLocal ()
|
|||||||
if (!mHaveBase)
|
if (!mHaveBase)
|
||||||
{
|
{
|
||||||
// Nothing we can do without the ledger base
|
// Nothing we can do without the ledger base
|
||||||
HashedObject::pointer node = getApp().getHashedObjectStore ().retrieve (mHash);
|
NodeObject::pointer node = getApp().getHashedObjectStore ().retrieve (mHash);
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1535,7 +1535,7 @@ void PeerImp::recvGetObjectByHash (const boost::shared_ptr<protocol::TMGetObject
|
|||||||
if (obj.has_hash () && (obj.hash ().size () == (256 / 8)))
|
if (obj.has_hash () && (obj.hash ().size () == (256 / 8)))
|
||||||
{
|
{
|
||||||
memcpy (hash.begin (), obj.hash ().data (), 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)
|
if (hObj)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -824,7 +824,7 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternalNT (const SHAMapNode& id, uint2
|
|||||||
if (!getApp().running ())
|
if (!getApp().running ())
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
HashedObject::pointer obj (getApp().getHashedObjectStore ().retrieve (hash));
|
NodeObject::pointer obj (getApp().getHashedObjectStore ().retrieve (hash));
|
||||||
|
|
||||||
if (!obj)
|
if (!obj)
|
||||||
{
|
{
|
||||||
@@ -913,7 +913,7 @@ int SHAMap::armDirty ()
|
|||||||
return ++mSeq;
|
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;
|
int flushed = 0;
|
||||||
Serializer s;
|
Serializer s;
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public:
|
|||||||
bool compare (SHAMap::ref otherMap, Delta & differences, int maxCount);
|
bool compare (SHAMap::ref otherMap, Delta & differences, int maxCount);
|
||||||
|
|
||||||
int armDirty ();
|
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 ();
|
boost::shared_ptr<DirtyMap> disarmDirty ();
|
||||||
|
|
||||||
void setSeq (uint32 seq)
|
void setSeq (uint32 seq)
|
||||||
|
|||||||
Reference in New Issue
Block a user