mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Support bulk writes.
This commit is contained in:
@@ -119,4 +119,14 @@ HashedObject::pointer HashedObject::retrieve(const uint256& hash)
|
||||
return obj;
|
||||
}
|
||||
|
||||
HashedObjectBulkWriter::HashedObjectBulkWriter() : sl(theApp->getHashNodeDB()->getDBLock())
|
||||
{
|
||||
theApp->getHashNodeDB()->getDB()->executeSQL("BEGIN TRANSACTION;");
|
||||
}
|
||||
|
||||
HashedObjectBulkWriter::~HashedObjectBulkWriter()
|
||||
{
|
||||
theApp->getHashNodeDB()->getDB()->executeSQL("END TRANSACTION;");
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -3,18 +3,17 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "types.h"
|
||||
#include "uint256.h"
|
||||
#include "ScopedLock.h"
|
||||
|
||||
enum HashedObjectType
|
||||
{
|
||||
UNKNOWN=0,
|
||||
LEDGER=1,
|
||||
TRANSACTION=2,
|
||||
ACCOUNT_NODE=3,
|
||||
TRANSACTION_NODE=4
|
||||
UNKNOWN = 0,
|
||||
LEDGER = 1,
|
||||
TRANSACTION = 2,
|
||||
ACCOUNT_NODE = 3,
|
||||
TRANSACTION_NODE = 4
|
||||
};
|
||||
|
||||
class HashedObject
|
||||
@@ -37,10 +36,27 @@ public:
|
||||
const std::vector<unsigned char>& getData() { return mData; }
|
||||
|
||||
bool store() const;
|
||||
|
||||
static bool store(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
|
||||
const uint256& hash);
|
||||
|
||||
static HashedObject::pointer retrieve(const uint256& hash);
|
||||
};
|
||||
|
||||
class HashedObjectBulkWriter
|
||||
{
|
||||
protected:
|
||||
ScopedLock sl;
|
||||
|
||||
public:
|
||||
|
||||
HashedObjectBulkWriter();
|
||||
~HashedObjectBulkWriter();
|
||||
|
||||
bool store(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data, const uint256& hash)
|
||||
{ return HashedObject::store(type, index, data, hash); }
|
||||
HashedObject::pointer retrieve(const uint256& hash)
|
||||
{ return HashedObject::retrieve(hash); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user